Serilog.Sinks.AzureLogAnalytics 6.7.0

dotnet add package Serilog.Sinks.AzureLogAnalytics --version 6.7.0                
NuGet\Install-Package Serilog.Sinks.AzureLogAnalytics -Version 6.7.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.AzureLogAnalytics" Version="6.7.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.AzureLogAnalytics --version 6.7.0                
#r "nuget: Serilog.Sinks.AzureLogAnalytics, 6.7.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Sinks.AzureLogAnalytics as a Cake Addin
#addin nuget:?package=Serilog.Sinks.AzureLogAnalytics&version=6.7.0

// Install Serilog.Sinks.AzureLogAnalytics as a Cake Tool
#tool nuget:?package=Serilog.Sinks.AzureLogAnalytics&version=6.7.0                

Serilog.Sinks.AzureLogAnalytics

High performance Serilog sink that writes to Azure Log Analytics. It supports automatic batching of log messages for better performance and auto-recovery from transient errors.

Getting started

Install Serilog.Sinks.AzureLogAnalytics from NuGet

Install-Package Serilog
Install-Package Serilog.Settings.Configuration
Install-Package Serilog.Sinks.AzureLogAnalytics
Install-Package Microsoft.Extensions.Configuration.Json

Configure logger by calling WriteTo.AzureLogAnalytics(<credentials>, <configSettings>)

credentials: A structure with required information to access Azure Log Ingestion API. to from Azure OMS Portal connected sources. This parameter accepts:

Parameter name Meaning
endpoint Logs Ingestion URL for data collection endpoint.
immutableId ImmutableId for Data Collection Rules (DCR).
streamName Output stream name of target (Log Analytics API, can be accessed from DCR).
tenantId Directory (tenant) Id of registered application (Microsoft Entra ID).
clientId Application (client) Id of Microsoft Entra application.
clientSecret Client secret for registered Entra Application.
Log.Logger = new LoggerConfiguration()
    .WriteTo.AzureLogAnalytics(<credentials>, <configSettings>)
    .CreateLogger();

Formatting event JSON

To adjust the format of the event JSON populated into Azure Log Analytics, pass an ITextFormatter as the first argument:

Log.Logger = new LoggerConfiguration()
    .WriteTo.AzureLogAnalytics(new CompactJsonFormatter(), <credentials>, <configSettings>)
    .CreateLogger();

JSON appsettings configuration

In your appsettings.json file, configure following:

{
  "Serilog": {
    "Using": [ "Serilog.Sinks.AzureLogAnalytics" ],
    "MinimumLevel": "Verbose",
    "WriteTo": [
      {
        "Name": "AzureLogAnalytics",
        "Args": {
          "credentials": {
            "endpoint": "https://****.****.ingest.monitor.azure.com",
            "immutableId": "dcr-****",
            "streamName": "Custom-****_CL",
            "tenantId": "****-****-****-****-****",
            "clientId": "****-****-****-****-****",
            "clientSecret": "*******"
          },
          "configSettings": {
            "bufferSize": "5000",
            "batchSize": "100"
          }
        }
      }
    ]
  }
}

To configure and instanciate AzureLogAnalytics sink in appsettings.json, in your code, call:


var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json").Build();

Log.Logger = new LoggerConfiguration()
                .ReadFrom.Configuration(configuration)
                .CreateLogger();

Tutorial: Send data to Azure Monitor Logs with Logs ingestion API (Azure portal) is good resource to configure environment for Log Ingestion API in Azure portal.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.7.0 881 12/4/2024
6.6.7 140,565 5/10/2024
6.6.6 142 5/10/2024
6.6.0 418 5/5/2024
6.5.0 113,430 4/8/2024
6.2.0 9,595 2/10/2024
6.1.0 1,022 1/21/2024