Make sure AzureAppServices logger is resolvable from DI contatiner (#1039)

This commit is contained in:
Pavel Krymets 2019-01-31 12:37:12 -08:00 committed by GitHub
parent 6d452e9b05
commit 478a18fb73
4 changed files with 14 additions and 2 deletions

View File

@ -35,6 +35,8 @@ namespace Microsoft.Extensions.Logging
return builder;
}
builder.AddConfiguration();
var config = SiteConfigurationProvider.GetAzureLoggingConfiguration(context);
var services = builder.Services;

View File

@ -28,7 +28,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
/// Creates a new instance of <see cref="BlobLoggerProvider"/>
/// </summary>
/// <param name="options"></param>
internal BlobLoggerProvider(IOptionsMonitor<AzureBlobLoggerOptions> options)
public BlobLoggerProvider(IOptionsMonitor<AzureBlobLoggerOptions> options)
: this(options, null)
{
_blobReferenceFactory = name => new BlobAppendReferenceWrapper(

View File

@ -18,7 +18,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
private readonly int? _maxFileSize;
private readonly int? _maxRetainedFiles;
internal FileLoggerProvider(IOptionsMonitor<AzureFileLoggerOptions> options) : base(options)
public FileLoggerProvider(IOptionsMonitor<AzureFileLoggerOptions> options) : base(options)
{
var loggerOptions = options.CurrentValue;
_path = loggerOptions.LogDirectory;

View File

@ -64,5 +64,15 @@ namespace Microsoft.Extensions.Logging.AzureAppServices.Test
Assert.Equal(4, serviceCollection.Count(d => d.ServiceType == typeof(IConfigureOptions<LoggerFilterOptions>)));
}
[Fact]
public void LoggerProviderIsResolvable()
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder => builder.AddAzureWebAppDiagnostics(_appContext));
var serviceProvider = serviceCollection.BuildServiceProvider();
var loggerFactory = serviceProvider.GetService<ILoggerProvider>();
}
}
}