A Serilog sink that supports Azure App Services 'Diagnostics logs' and 'Log stream' features.
Write Serilog events to Azure Diagnostics Application Logging using Microsoft.Extensions.Logging and Microsoft.Extensions.Logging.AzureAppServices. Enables using the the Azure Log Stream and Blob storage for events.
Designed to be used with Serilog.AspNetCore. Works with UseSerilog()
.
To add Serilog:
dotnet add package Serilog.AspNetCore
dotnet add package Serilog.Sinks.AzureApp
In Program.cs
:
Add reference and update the Main
method:
using Serilog;
[...]
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
[...]
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
Diagnostic logs and log stream are configured in the Azure App Service's Monitoring section.