Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// 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.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;
Expand Down Expand Up @@ -93,103 +92,5 @@ private static ConfigurationBasedLevelSwitcher CreateFileFilterConfigureOptions(
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -36,4 +35,4 @@ public string BlobName

internal string ApplicationInstanceId { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,4 +33,4 @@ private static bool TextToBoolean(string text)
return result;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -73,4 +73,4 @@ public int? BatchSize
/// </summary>
public bool IncludeScopes { get; set; } = false;
}
}
}
Loading