cnelsonakgov / serilog-sinks-azureapp

A Serilog sink that supports Azure App Services 'Diagnostics logs' and 'Log stream' features.
Creative Commons Zero v1.0 Universal
17 stars 2 forks source link

Serilog.Sinks.AzureApp NuGet Version

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().

Install

To add Serilog:

dotnet add package Serilog.AspNetCore
dotnet add package Serilog.Sinks.AzureApp

Basic Setup

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.