Remove obsolete types from Azure logging (#498)

This commit is contained in:
Pavel Krymets 2018-11-14 12:46:22 -08:00 committed by GitHub
parent ef4b214125
commit 8a586ceb57
33 changed files with 116 additions and 388 deletions

View File

@ -1,162 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <summary>
/// Settings for Azure diagnostics logging.
/// </summary>
[Obsolete("This type is obsolete and will be removed in a future version. The recommended alternative is AzureBlobLoggerOptions.")]
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;
/// <summary>
/// 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 <c>10MB</c>.
/// </summary>
public int FileSizeLimit
{
get { return _fileSizeLimit; }
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FileSizeLimit)} must be positive.");
}
_fileSizeLimit = value;
}
}
/// <summary>
/// Gets or sets a strictly positive value representing the maximum retained file count.
/// Defaults to <c>2</c>.
/// </summary>
public int RetainedFileCountLimit
{
get { return _retainedFileCountLimit; }
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(RetainedFileCountLimit)} must be positive.");
}
_retainedFileCountLimit = value;
}
}
/// <summary>
/// Gets or sets a message template describing the output messages.
/// Defaults to <c>"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"</c>.
/// </summary>
public string OutputTemplate
{
get { return _outputTemplate; }
set
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentException(nameof(value), $"{nameof(OutputTemplate)} must be non-empty string.");
}
_outputTemplate = value;
}
}
/// <summary>
/// Gets or sets a maximum number of events to include in a single blob append batch.
/// Defaults to <c>32</c>.
/// </summary>
public int BlobBatchSize
{
get { return _blobBatchSize; }
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BlobBatchSize)} must be positive.");
}
_blobBatchSize = value;
}
}
/// <summary>
/// Gets or sets a time to wait between checking for blob log batches.
/// Defaults to 5 seconds.
/// </summary>
public TimeSpan BlobCommitPeriod
{
get { return _blobCommitPeriod; }
set
{
if (value < TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BlobCommitPeriod)} must be positive.");
}
_blobCommitPeriod = value;
}
}
/// <summary>
/// Gets or sets the last section of log blob name.
/// Defaults to <c>"applicationLog.txt"</c>.
/// </summary>
public string BlobName
{
get { return _blobName; }
set
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentException(nameof(value), $"{nameof(BlobName)} must be non-empty string.");
}
_blobName = value;
}
}
/// <summary>
/// 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 <c>0</c>.
/// </summary>
public int BackgroundQueueSize
{
get { return _backgroundQueueSize; }
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(BackgroundQueueSize)} must be non-negative.");
}
_backgroundQueueSize = value;
}
}
/// <summary>
/// Gets or sets the period after which logs will be flushed to disk or
/// <c>null</c> if auto flushing is not required.
/// Defaults to 1 second.
/// </summary>
public TimeSpan? FileFlushPeriod
{
get { return _fileFlushPeriod; }
set
{
if (value < TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FileFlushPeriod)} must be positive.");
}
_fileFlushPeriod = value;
}
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -6,7 +6,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging.AzureAppServices;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Options;
using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor;
@ -93,103 +92,5 @@ namespace Microsoft.Extensions.Logging
provider: typeof(FileLoggerProvider),
levelKey: "AzureDriveTraceLevel");
}
/// <summary>
/// Adds an Azure Web Apps diagnostics logger.
/// </summary>
/// <param name="factory">The extension method argument</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is AddAzureWebAppDiagnostics(this ILoggingBuilder builder).")]
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory)
{
return AddAzureWebAppDiagnostics(factory, new AzureAppServicesDiagnosticsSettings());
}
/// <summary>
/// Adds an Azure Web Apps diagnostics logger.
/// </summary>
/// <param name="factory">The extension method argument</param>
/// <param name="settings">The setting object to configure loggers.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is AddAzureWebAppDiagnostics(this ILoggingBuilder builder).")]
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory, AzureAppServicesDiagnosticsSettings settings)
{
var context = WebAppContext.Default;
if (!context.IsRunningInAzureWebApp)
{
return factory;
}
var config = SiteConfigurationProvider.GetAzureLoggingConfiguration(context);
// Only add the provider if we're in Azure WebApp. That cannot change once the apps started
var fileOptions = new OptionsMonitor<AzureFileLoggerOptions>(
new OptionsFactory<AzureFileLoggerOptions>(
new IConfigureOptions<AzureFileLoggerOptions>[]
{
new FileLoggerConfigureOptions(config, context),
new ConfigureOptions<AzureFileLoggerOptions>(options =>
{
options.FileSizeLimit = settings.FileSizeLimit;
options.RetainedFileCountLimit = settings.RetainedFileCountLimit;
options.BackgroundQueueSize = settings.BackgroundQueueSize == 0 ? (int?) null : settings.BackgroundQueueSize;
if (settings.FileFlushPeriod != null)
{
options.FlushPeriod = settings.FileFlushPeriod.Value;
}
})
},
new IPostConfigureOptions<AzureFileLoggerOptions>[0]
),
new[]
{
new ConfigurationChangeTokenSource<AzureFileLoggerOptions>(config)
},
new OptionsCache<AzureFileLoggerOptions>()
);
var blobOptions = new OptionsMonitor<AzureBlobLoggerOptions>(
new OptionsFactory<AzureBlobLoggerOptions>(
new IConfigureOptions<AzureBlobLoggerOptions>[] {
new BlobLoggerConfigureOptions(config, context),
new ConfigureOptions<AzureBlobLoggerOptions>(options =>
{
options.BlobName = settings.BlobName;
options.FlushPeriod = settings.BlobCommitPeriod;
options.BatchSize = settings.BlobBatchSize;
options.BackgroundQueueSize = settings.BackgroundQueueSize == 0 ? (int?) null : settings.BackgroundQueueSize;
})
},
new IPostConfigureOptions<AzureBlobLoggerOptions>[0]
),
new[]
{
new ConfigurationChangeTokenSource<AzureBlobLoggerOptions>(config)
},
new OptionsCache<AzureBlobLoggerOptions>()
);
var filterOptions = new OptionsMonitor<LoggerFilterOptions>(
new OptionsFactory<LoggerFilterOptions>(
new[]
{
CreateFileFilterConfigureOptions(config),
CreateBlobFilterConfigureOptions(config)
},
new IPostConfigureOptions<LoggerFilterOptions>[0]),
new [] { new ConfigurationChangeTokenSource<LoggerFilterOptions>(config) },
new OptionsCache<LoggerFilterOptions>());
factory.AddProvider(new ForwardingLoggerProvider(
new LoggerFactory(
new ILoggerProvider[]
{
new FileLoggerProvider(fileOptions),
new BlobLoggerProvider(blobOptions)
},
filterOptions
)
));
return factory;
}
}
}

View File

@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
namespace Microsoft.Extensions.Logging.AzureAppServices
{
@ -36,4 +35,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
internal string ApplicationInstanceId { get; set; }
}
}
}

View File

@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
namespace Microsoft.Extensions.Logging.AzureAppServices
{

View File

@ -4,9 +4,9 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class BatchLoggerConfigureOptions : IConfigureOptions<BatchingLoggerOptions>
internal class BatchLoggerConfigureOptions : IConfigureOptions<BatchingLoggerOptions>
{
private readonly IConfiguration _configuration;
private readonly string _isEnabledKey;
@ -33,4 +33,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
return result;
}
}
}
}

View File

@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class BatchingLogger : ILogger
internal class BatchingLogger : ILogger
{
private readonly BatchingLoggerProvider _provider;
private readonly string _category;

View File

@ -1,9 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class BatchingLoggerOptions
{
@ -73,4 +73,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
/// </summary>
public bool IncludeScopes { get; set; } = false;
}
}
}

View File

@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public abstract class BatchingLoggerProvider: ILoggerProvider, ISupportExternalScope
{
@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
internal IExternalScopeProvider ScopeProvider => _includeScopes ? _scopeProvider : null;
protected BatchingLoggerProvider(IOptionsMonitor<BatchingLoggerOptions> options)
internal BatchingLoggerProvider(IOptionsMonitor<BatchingLoggerOptions> options)
{
// NOTE: Only IsEnabled is monitored
@ -73,7 +73,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
}
protected abstract Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token);
internal abstract Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token);
private async Task ProcessLogQueue(object state)
{
@ -90,11 +90,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
var messagesDropped = Interlocked.Exchange(ref _messagesDropped, 0);
if (messagesDropped != 0)
{
_currentBatch.Add(new LogMessage()
{
Message = $"{messagesDropped} message(s) dropped because of queue size limit. Increase the queue size or decrease logging verbosity to avoid this.{Environment.NewLine}",
Timestamp = DateTimeOffset.Now
});
_currentBatch.Add(new LogMessage(DateTimeOffset.Now, $"{messagesDropped} message(s) dropped because of queue size limit. Increase the queue size or decrease logging verbosity to avoid this.{Environment.NewLine}"));
}
if (_currentBatch.Count > 0)
@ -128,7 +124,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
{
try
{
if (!_messageQueue.TryAdd(new LogMessage { Message = message, Timestamp = timestamp }, millisecondsTimeout: 0, cancellationToken: _cancellationTokenSource.Token))
if (!_messageQueue.TryAdd(new LogMessage(timestamp, message), millisecondsTimeout: 0, cancellationToken: _cancellationTokenSource.Token))
{
Interlocked.Increment(ref _messagesDropped);
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -7,10 +7,10 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <inheritdoc />
public class BlobAppendReferenceWrapper : ICloudAppendBlob
internal class BlobAppendReferenceWrapper : ICloudAppendBlob
{
private readonly Uri _fullUri;
private readonly HttpClient _client;
@ -93,4 +93,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
uriBuilder.Query = queryToAppend;
}
}
}
}

View File

@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class BlobLoggerConfigureOptions : BatchLoggerConfigureOptions, IConfigureOptions<AzureBlobLoggerOptions>
internal class BlobLoggerConfigureOptions : BatchLoggerConfigureOptions, IConfigureOptions<AzureBlobLoggerOptions>
{
private readonly IConfiguration _configuration;
private readonly IWebAppContext _context;
@ -26,4 +26,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
options.ApplicationInstanceId = _context.SiteInstanceId;
}
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -11,7 +11,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <summary>
/// The <see cref="ILoggerProvider"/> implementation that stores messages by appending them to Azure Blob in batches.
@ -28,7 +28,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
/// Creates a new instance of <see cref="BlobLoggerProvider"/>
/// </summary>
/// <param name="options"></param>
public BlobLoggerProvider(IOptionsMonitor<AzureBlobLoggerOptions> options)
internal BlobLoggerProvider(IOptionsMonitor<AzureBlobLoggerOptions> options)
: this(options, null)
{
_blobReferenceFactory = name => new BlobAppendReferenceWrapper(
@ -42,7 +42,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
/// </summary>
/// <param name="blobReferenceFactory">The container to store logs to.</param>
/// <param name="options"></param>
public BlobLoggerProvider(
internal BlobLoggerProvider(
IOptionsMonitor<AzureBlobLoggerOptions> options,
Func<string, ICloudAppendBlob> blobReferenceFactory) :
base(options)
@ -54,7 +54,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
_httpClient = new HttpClient();
}
protected override async Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken cancellationToken)
internal override async Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken cancellationToken)
{
var eventGroups = messages.GroupBy(GetBlobKey);
foreach (var eventGroup in eventGroups)
@ -88,4 +88,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
e.Timestamp.Hour);
}
}
}
}

View File

@ -1,13 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class ConfigurationBasedLevelSwitcher: IConfigureOptions<LoggerFilterOptions>
internal class ConfigurationBasedLevelSwitcher: IConfigureOptions<LoggerFilterOptions>
{
private readonly IConfiguration _configuration;
private readonly Type _provider;
@ -47,4 +47,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
}
}
}
}
}

View File

@ -1,13 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class FileLoggerConfigureOptions : BatchLoggerConfigureOptions, IConfigureOptions<AzureFileLoggerOptions>
internal class FileLoggerConfigureOptions : BatchLoggerConfigureOptions, IConfigureOptions<AzureFileLoggerOptions>
{
private readonly IWebAppContext _context;
@ -23,4 +23,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
options.LogDirectory = Path.Combine(_context.HomeFolder, "LogFiles", "Application");
}
}
}
}

View File

@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
[ProviderAlias("AzureAppServicesFile")]
public class FileLoggerProvider : BatchingLoggerProvider
@ -18,7 +18,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
private readonly int? _maxFileSize;
private readonly int? _maxRetainedFiles;
public FileLoggerProvider(IOptionsMonitor<AzureFileLoggerOptions> options) : base(options)
internal FileLoggerProvider(IOptionsMonitor<AzureFileLoggerOptions> options) : base(options)
{
var loggerOptions = options.CurrentValue;
_path = loggerOptions.LogDirectory;
@ -27,7 +27,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
_maxRetainedFiles = loggerOptions.RetainedFileCountLimit;
}
protected override async Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken cancellationToken)
internal override async Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken cancellationToken)
{
Directory.CreateDirectory(_path);
@ -57,12 +57,12 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
return Path.Combine(_path, $"{_fileName}{group.Year:0000}{group.Month:00}{group.Day:00}.txt");
}
public (int Year, int Month, int Day) GetGrouping(LogMessage message)
private (int Year, int Month, int Day) GetGrouping(LogMessage message)
{
return (message.Timestamp.Year, message.Timestamp.Month, message.Timestamp.Day);
}
protected void RollFiles()
private void RollFiles()
{
if (_maxRetainedFiles > 0)
{
@ -78,4 +78,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
}
}
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -6,12 +6,12 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <summary>
/// Represents an append blob, a type of blob where blocks of data are always committed to the end of the blob.
/// </summary>
public interface ICloudAppendBlob
internal interface ICloudAppendBlob
{
/// <summary>
/// Initiates an asynchronous operation to open a stream for writing to the blob.
@ -19,4 +19,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
/// <returns>A <see cref="T:System.Threading.Tasks.Task`1" /> object of type <see cref="Stream" /> that represents the asynchronous operation.</returns>
Task AppendAsync(ArraySegment<byte> data, CancellationToken cancellationToken);
}
}
}

View File

@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <summary>
/// Represents an Azure WebApp context
/// </summary>
public interface IWebAppContext
internal interface IWebAppContext
{
/// <summary>
/// Gets the path to the home folder if running in Azure WebApp

View File

@ -1,25 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
{
internal class ForwardingLoggerProvider : ILoggerProvider
{
private readonly ILoggerFactory _loggerFactory;
public ForwardingLoggerProvider(ILoggerFactory loggerFactory)
{
_loggerFactory = loggerFactory;
}
public void Dispose()
{
_loggerFactory.Dispose();
}
public ILogger CreateLogger(string categoryName)
{
return _loggerFactory.CreateLogger(categoryName);
}
}
}

View File

@ -1,13 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
{
public struct LogMessage
{
public DateTimeOffset Timestamp { get; set; }
public string Message { get; set; }
}
}

View File

@ -0,0 +1,19 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Extensions.Logging.AzureAppServices
{
internal readonly struct LogMessage
{
public LogMessage(DateTimeOffset timestamp, string message)
{
Timestamp = timestamp;
Message = message;
}
public DateTimeOffset Timestamp { get; }
public string Message { get; }
}
}

View File

@ -5,3 +5,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.AzureAppServices.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

View File

@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
public class SiteConfigurationProvider
internal class SiteConfigurationProvider
{
public static IConfiguration GetAzureLoggingConfiguration(IWebAppContext context)
{
@ -19,4 +19,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
.Build();
}
}
}
}

View File

@ -1,14 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
namespace Microsoft.Extensions.Logging.AzureAppServices
{
/// <summary>
/// Represents the default implementation of <see cref="IWebAppContext"/>.
/// </summary>
public class WebAppContext : IWebAppContext
internal class WebAppContext : IWebAppContext
{
/// <summary>
/// Gets the default instance of the WebApp context.

View File

@ -0,0 +1,24 @@
[
{
"TypeId": "public class Microsoft.Extensions.Logging.AzureAppServices.AzureAppServicesDiagnosticsSettings",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.Extensions.Logging.AzureAppServices.AzureBlobLoggerOptions : Microsoft.Extensions.Logging.AzureAppServices.Internal.BatchingLoggerOptions",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.Extensions.Logging.AzureAppServices.AzureFileLoggerOptions : Microsoft.Extensions.Logging.AzureAppServices.Internal.BatchingLoggerOptions",
"Kind": "Removal"
},
{
"TypeId": "public static class Microsoft.Extensions.Logging.AzureAppServicesLoggerFactoryExtensions",
"MemberId": "public static Microsoft.Extensions.Logging.ILoggerFactory AddAzureWebAppDiagnostics(this Microsoft.Extensions.Logging.ILoggerFactory factory)",
"Kind": "Removal"
},
{
"TypeId": "public static class Microsoft.Extensions.Logging.AzureAppServicesLoggerFactoryExtensions",
"MemberId": "public static Microsoft.Extensions.Logging.ILoggerFactory AddAzureWebAppDiagnostics(this Microsoft.Extensions.Logging.ILoggerFactory factory, Microsoft.Extensions.Logging.AzureAppServices.AzureAppServicesDiagnosticsSettings settings)",
"Kind": "Removal"
}
]

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -6,7 +6,6 @@ using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Xunit;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -9,7 +9,6 @@ using System.Threading;
using System.Threading.Tasks;
using Moq;
using Xunit;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test
{

View File

@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Moq;
using Xunit;
@ -67,4 +66,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
}
}
}
}
}

View File

@ -7,7 +7,6 @@ using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Xunit;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test
@ -121,7 +120,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
{
}
protected override Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token)
internal override Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token)
{
Batches.Add(messages.ToArray());
return Task.CompletedTask;

View File

@ -1,11 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Moq;
using Xunit;

View File

@ -5,7 +5,6 @@ using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Xunit;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test
@ -119,4 +118,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
}, actualFiles);
}
}
}
}

View File

@ -1,10 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Microsoft.Extensions.Options;
using Moq;
using Xunit;
@ -66,4 +65,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
Assert.Equal(4, serviceCollection.Count(d => d.ServiceType == typeof(IConfigureOptions<LoggerFilterOptions>)));
}
}
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test
{
@ -27,4 +25,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
return IntervalControl.IntervalAsync();
}
}
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test
{
@ -33,4 +32,4 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
return IntervalControl.IntervalAsync();
}
}
}
}

View File

@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;
using Xunit;
namespace Microsoft.Extensions.Logging.AzureAppServices.Test