Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.Extensions.Logging.AzureAppServicesMicrosoft.Extensions.Logging.AzureAppServices provides a logger implementation that logs to text files in an Azure App Service app's file system and to blob storage in an Azure Storage account.
Microsoft.Extensions.LoggingTo use Microsoft.Extensions.Logging.AzureAppServices, follow these steps:
dotnet add package Microsoft.Extensions.Logging.AzureAppServices
To configure provider settings, use AzureFileLoggerOptions and AzureBlobLoggerOptions, as shown in the following example:
using Microsoft.Extensions.Logging.AzureAppServices;
var builder = WebApplication.CreateBuilder();
builder.Logging.AddAzureWebAppDiagnostics();
builder.Services.Configure<AzureFileLoggerOptions>(options =>
{
options.FileName = "azure-diagnostics-";
options.FileSizeLimit = 50 * 1024;
options.RetainedFileCountLimit = 5;
});
builder.Services.Configure<AzureBlobLoggerOptions>(options =>
{
options.BlobName = "log.txt";
});
FileLoggerProvider: A BatchingLoggerProvider which writes out to a fileBlobLoggerProvider: The ILoggerProvider implementation that stores messages by appending them to Azure Blob in batchesAzureFileLoggerOptions: Options for configuring Azure diagnostics file loggingAzureBlobLoggerOptions: Options for configuring Azure diagnostics blob loggingFor additional documentation and examples, refer to the on logging with ASP.NEt Core and Azure App Service.
Microsoft.Extensions.Logging.AzureAppServices is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.