diff --git a/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs b/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs
index eb38fa34..4da2d253 100644
--- a/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs
+++ b/src/Microsoft.Extensions.Logging.AzureAppServices/AzureAppServicesDiagnosticsSettings.cs
@@ -11,44 +11,152 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
///
public class AzureAppServicesDiagnosticsSettings
{
+ private TimeSpan _blobCommitPeriod = TimeSpan.FromSeconds(5);
+ private int _blobBatchSize = 32;
+ private string _outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
+ private int _retainedFileCountLimit = 2;
+ private int _fileSizeLimit = 10 * 1024 * 1024;
+ private string _blobName = "applicationLog.txt";
+ private TimeSpan? _fileFlushPeriod = TimeSpan.FromSeconds(1);
+ private int _backgroundQueueSize;
+
///
- /// Gets or sets a strictly positive value representing the maximum log size in bytes. Once the log is full, no more message will be appended.
+ /// Gets or sets a strictly positive value representing the maximum log size in bytes.
+ /// Once the log is full, no more messages will be appended.
+ /// Defaults to 10MB.
///
- public int FileSizeLimit { get; set; } = 10 * 1024 * 1024;
+ public int FileSizeLimit
+ {
+ get { return _fileSizeLimit; }
+ set
+ {
+ if (value <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FileSizeLimit)} must be positive.");
+ }
+ _fileSizeLimit = value;
+ }
+ }
///
/// Gets or sets a strictly positive value representing the maximum retained file count.
+ /// Defaults to 2.
///
- public int RetainedFileCountLimit { get; set; } = 2;
+ public int RetainedFileCountLimit
+ {
+ get { return _retainedFileCountLimit; }
+ set
+ {
+ if (value <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(RetainedFileCountLimit)} must be positive.");
+ }
+ _retainedFileCountLimit = value;
+ }
+ }
///
/// Gets or sets a message template describing the output messages.
+ /// Defaults to "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}".
///
- public string OutputTemplate { get; set; } = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
+ public string OutputTemplate
+ {
+ get { return _outputTemplate; }
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException(nameof(value), $"{nameof(OutputTemplate)} must be non-empty string.");
+ }
+ _outputTemplate = value;
+ }
+ }
///
/// Gets or sets a maximum number of events to include in a single blob append batch.
+ /// Defaults to 32.
///
- public int BlobBatchSize { get; set; } = 32;
+ public int BlobBatchSize
+ {
+ get { return _blobBatchSize; }
+ set
+ {
+ if (value <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BlobBatchSize)} must be positive.");
+ }
+ _blobBatchSize = value;
+ }
+ }
///
/// Gets or sets a time to wait between checking for blob log batches.
+ /// Defaults to 5 seconds.
///
- public TimeSpan BlobCommitPeriod { get; set; } = TimeSpan.FromSeconds(5);
+ public TimeSpan BlobCommitPeriod
+ {
+ get { return _blobCommitPeriod; }
+ set
+ {
+ if (value < TimeSpan.Zero)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BlobCommitPeriod)} must be positive.");
+ }
+ _blobCommitPeriod = value;
+ }
+ }
///
/// Gets or sets the last section of log blob name.
+ /// Defaults to "applicationLog.txt".
///
- public string BlobName { get; set; } = "applicationLog.txt";
+ public string BlobName
+ {
+ get { return _blobName; }
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException(nameof(value), $"{nameof(BlobName)} must be non-empty string.");
+ }
+ _blobName = value;
+ }
+ }
///
- /// Gets of sets the maximum size of the background log message queue.
+ /// Gets or sets the maximum size of the background log message queue or 0 for no limit.
+ /// After maximum queue size is reached log event sink would start blocking.
+ /// Defaults to 0.
///
- public int BackgroundQueueSize { get; set; }
+ public int BackgroundQueueSize
+ {
+ get { return _backgroundQueueSize; }
+ set
+ {
+ if (value < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BackgroundQueueSize)} must be positive or 0.");
+ }
+ _backgroundQueueSize = value;
+ }
+ }
///
- /// Gets or sets the period after which logs will be flushed to disk.
+ /// Gets or sets the period after which logs will be flushed to disk or
+ /// null if auto flushing is not required.
+ /// Defaults to 1 second.
///
- public TimeSpan? FileFlushPeriod { get; set; } = TimeSpan.FromSeconds(1);
+ public TimeSpan? FileFlushPeriod
+ {
+ get { return _fileFlushPeriod; }
+ set
+ {
+ if (value < TimeSpan.Zero)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FileFlushPeriod)} must be positive.");
+ }
+ _fileFlushPeriod = value;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/AzureBlobSink.cs b/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/AzureBlobSink.cs
index b8166955..e99302d0 100644
--- a/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/AzureBlobSink.cs
+++ b/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/AzureBlobSink.cs
@@ -54,11 +54,11 @@ public AzureBlobSink(Func blobReferenceFactory,
}
if (batchSizeLimit <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(batchSizeLimit), $"{nameof(batchSizeLimit)} should be a positive number.");
+ throw new ArgumentOutOfRangeException(nameof(batchSizeLimit), $"{nameof(batchSizeLimit)} must be a positive number.");
}
if (period <= TimeSpan.Zero)
{
- throw new ArgumentOutOfRangeException(nameof(period), $"{nameof(period)} should be longer than zero.");
+ throw new ArgumentOutOfRangeException(nameof(period), $"{nameof(period)} must be longer than zero.");
}
_appName = appName;
diff --git a/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/FileLoggerProvider.cs b/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/FileLoggerProvider.cs
index bdc24eb6..f3aae7d4 100644
--- a/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/FileLoggerProvider.cs
+++ b/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/FileLoggerProvider.cs
@@ -40,11 +40,11 @@ public FileLoggerProvider(int fileSizeLimit, int retainedFileCountLimit, int bac
}
if (fileSizeLimit <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(fileSizeLimit), $"{nameof(fileSizeLimit)} should be positive.");
+ throw new ArgumentOutOfRangeException(nameof(fileSizeLimit), $"{nameof(fileSizeLimit)} must be positive.");
}
if (retainedFileCountLimit <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(retainedFileCountLimit), $"{nameof(retainedFileCountLimit)} should be positive.");
+ throw new ArgumentOutOfRangeException(nameof(retainedFileCountLimit), $"{nameof(retainedFileCountLimit)} must be positive.");
}
_fileSizeLimit = fileSizeLimit;
diff --git a/src/Microsoft.Extensions.Logging.AzureAppServices/project.json b/src/Microsoft.Extensions.Logging.AzureAppServices/project.json
index 803bfa1c..79a5f707 100644
--- a/src/Microsoft.Extensions.Logging.AzureAppServices/project.json
+++ b/src/Microsoft.Extensions.Logging.AzureAppServices/project.json
@@ -1,6 +1,6 @@
{
"version": "1.0.0-*",
- "description": "Diagnostics logger for Azure WebApps",
+ "description": "Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.",
"packOptions": {
"tags": [
"logging"