![]() |
VOOZH | about |
dotnet add package Serilog.Sinks.AzureDataExplorer --version 2.0.4
NuGet\Install-Package Serilog.Sinks.AzureDataExplorer -Version 2.0.4
<PackageReference Include="Serilog.Sinks.AzureDataExplorer" Version="2.0.4" />
<PackageVersion Include="Serilog.Sinks.AzureDataExplorer" Version="2.0.4" />Directory.Packages.props
<PackageReference Include="Serilog.Sinks.AzureDataExplorer" />Project file
paket add Serilog.Sinks.AzureDataExplorer --version 2.0.4
#r "nuget: Serilog.Sinks.AzureDataExplorer, 2.0.4"
#:package Serilog.Sinks.AzureDataExplorer@2.0.4
#addin nuget:?package=Serilog.Sinks.AzureDataExplorer&version=2.0.4Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.AzureDataExplorer&version=2.0.4Install as a Cake Tool
A Serilog sink that writes events to an Azure Data Explorer (Kusto) cluster.
Package - Serilog.Sinks.AzureDataExplorer | Platforms - .NET 9.0, .NET 8.0, .NET 6.0, .NET Standard 2.0
Install from NuGet:
Install-Package Serilog.Sinks.AzureDataExplorer
This sink supports the durable mode where the logs are written to a file first and then flushed to the specified ADX table. This durable mode prevents data loss when the ADX connection couldnt be established. Durable mode can be turned on when we specify the bufferFileName in the LoggerConfiguration as mentioned below.
Configuration when durable mode is not required
var log = new LoggerConfiguration()
.WriteTo.AzureDataExplorer(new AzureDataExplorerSinkOptions
{
IngestionEndpointUri = "https://ingest-mycluster.northeurope.kusto.windows.net",
DatabaseName = "MyDatabase",
TableName = "Serilogs"
})
.CreateLogger();
Configuration when durable mode is required
var log = new LoggerConfiguration()
.WriteTo.AzureDataExplorer(new AzureDataExplorerSinkOptions
{
IngestionEndpointUri = "https://ingest-mycluster.northeurope.kusto.windows.net",
DatabaseName = "MyDatabase",
TableName = "Serilogs",
BufferBaseFileName = "BufferBaseFileName",
BufferFileRollingInterval = RollingInterval.Minute
})
.CreateLogger();
Note: Inorder to get the exception as string mapped to kusto column such as Exception, it is recommended to use ExceptionEx Attribute. For example:
new SinkColumnMapping { ColumnName ="Exception", ColumnType ="string", ValuePath = "$.ExceptionEx" }
You can configure the Azure Data Explorer Serilog Sink using an appsettings.json file. Below is a sample appsettings.json file that includes the Periodic Batching configuration options: batchPostingLimit, period, and queueSizeLimit.
Sample appsettings.json contents
{
"Serilog": {
"Using": [ "Serilog.Sinks.AzureDataExplorer" ],
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "AzureDataExplorerSink",
"Args": {
"ingestionUri": "https://ingest-cluster-name",
"databaseName": "sample",
"tableName": "table",
"applicationClientId": "xxxxxxxx",
"applicationSecret": "xxxxxxx",
"tenantId": "xxxxxxx",
"isManagedIdentity": false,
"isWorkloadIdentity": false,
"batchPostingLimit": 1000, // Optional
"period": 10.0, // Optional (in seconds)
"queueSizeLimit": 100000 // Optional
}
}
]
}
}
You can also configure the Azure Data Explorer Serilog Sink using an appsettings.xml file.
Sample appsettings.xml contents
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<Serilog>
<Using>Serilog.Sinks.File</Using>
<Using>Serilog.Sinks.AzureDataExplorer</Using>
<MinimumLevel Default="Verbose" />
<WriteTo>
<Args>
<Name>AzureDataExplorerSink</Name>
<Args>
<ingestionUri>https://ingest-cluster-name</ingestionUri>
<databaseName>DatabaseName</databaseName>
<tableName>TableName</tableName>
<applicationClientId>YOUR_CLIENT_ID</applicationClientId>
<applicationSecret>YOUR_APP_SECRET</applicationSecret>
<tenantId>YOUR_TENANT_ID</tenantId>
<batchPostingLimit>1000</batchPostingLimit>
<period>10</period>
<queueSizeLimit>100000</queueSizeLimit>
</Args>
</Args>
</WriteTo>
</Serilog>
</configuration>
Parameters for Periodic Batching:
batchPostingLimit: Specifies the maximum number of events to include in a batch. Defaults to 1000.
period: Specifies the time in seconds between checking for event batches to post. Defaults to 10 seconds.
queueSizeLimit: Specifies the maximum number of events in the queue. Once this limit is reached, new events will be dropped until the queue size decreases. Defaults to 100000.
The appsettings.json can be loaded through the following piece of code
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
Required NuGet Packages
Ensure you have the following NuGet dependencies to enable configuration through appsettings.json:
Azure Data Explorer provides data mapping capabilities, allowing the ability to extract data rom the ingested JSONs as part of the ingestion. This allows paying a one-time cost of processing the JSON during ingestion, and reduced cost at query time.
By default, the sink uses the following data mapping:
| Column Name | Column Type | JSON Path |
|---|---|---|
| Timestamp | datetime | $.Timestamp |
| Level | string | $.Level |
| Message | string | $.Message |
| Exception | string | $.Exception |
| Properties | dynamic | $.Properties |
This mapping can be overridden using the following options:
MappingName: Use a data mapping configured in ADX.
ColumnsMapping: Use an ingestion-time data mapping.
Note: If we need detailed exception messages along with stackTrace, innerExceptionDetails etc please use | Column Name | Column Type | JSON Path | |-------------|-------------|------------------| | Exception | string | $.ExceptionEx |
Durable mode can be turned on when we specify the bufferFileName in the LoggerConfiguration. There are few other options available when the durable mode is enabled.
BufferBaseFileName : Enables the durable mode. When specified, the logs are written to the bufferFileName first and then ingested to ADX.
BufferFileRollingInterval : The interval at which buffer log files will roll over to a new file. The default is RollingInterval.Hour
BufferLogShippingInterval : The interval between checking the buffer files.
BufferFileSizeLimitBytes : The maximum size, in bytes, to which the buffer log file for a specific date will be allowed to grow. By default 10 MB is applied
BufferFileLoggingLevelSwitch : A switch allowing the pass-through minimum level to be changed at runtime.
BufferFileCountLimit : The maximum number of log files that will be retained, including the current log file. For unlimited retention, pass null. The default is 20.
The sink supports authentication using various methods. Use one of the following methods to configure the desired authentication methods:
new AzureDataExplorerSinkOptions()
.WithXXX(...)
| Mode | Method | Notes |
|---|---|---|
| AadUserPrompt | WithAadUserPrompt | Recommended only development! |
| AadUserToken | WithAadUserToken | |
| AadApplicationCertificate | WithAadApplicationCertificate | |
| AadApplicationKey | WithAadApplicationKey | |
| AadApplicationSubjectName | WithAadApplicationSubjectName | |
| AadApplicationThumbprint | WithAadApplicationThumbprint | |
| AadApplicationToken | WithAadApplicationToken | |
| AadAzureTokenCredentials | WithAadAzureTokenCredentials | |
| AadUserManagedIdentity | WithAadUserManagedIdentity | |
| AadSystemManagedIdentity | WithAadSystemManagedIdentity | |
| AadWorkloadIdentity | WithWorkloadIdentity |
Note that if none of the authentication options are provided, AzCliIdentity , followed by AadUserPrompt will be attempted.
When configuring the sink through appsettings.json or appsettings.xml, only the credentials required by the
selected authentication mode need to be supplied:
| Mode | How to enable | Required parameters |
|---|---|---|
| AAD application key (default) | none of the options below are set | applicationClientId, applicationSecret, tenantId |
| Managed identity | set isManagedIdentity: true |
applicationClientId only — use "system" for a system-assigned identity, or the client id of a user-assigned identity |
| Workload identity | set isWorkloadIdentity: true |
none |
| User token | provide a non-empty userToken |
userToken only |
Setting more than one of isManagedIdentity, isWorkloadIdentity, or userToken throws an ArgumentException.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.4 | 126 | 6/10/2026 |
| 2.0.3 | 162 | 5/6/2026 |
| 2.0.2 | 288 | 3/13/2026 |
| 2.0.1 | 12,085 | 1/7/2026 |
| 2.0.0 | 15,699 | 8/6/2025 |
| 1.1.5 | 21,886 | 5/22/2025 |
| 1.1.4 | 1,596 | 4/9/2025 |
| 1.1.2 | 33,947 | 8/14/2024 |
| 1.1.1 | 4,581 | 8/2/2024 |
| 1.1.0 | 8,551 | 4/30/2024 |
| 1.0.9 | 1,254 | 3/19/2024 |
| 1.0.8 | 324 | 3/12/2024 |
| 1.0.7 | 353 | 3/5/2024 |
| 1.0.6 | 334 | 2/21/2024 |
| 1.0.5 | 1,204 | 1/26/2024 |
| 1.0.4 | 23,689 | 8/24/2023 |
| 1.0.3 | 7,362 | 3/9/2023 |
| 1.0.2 | 749 | 7/21/2022 |
| 1.0.1 | 696 | 7/11/2022 |
| 1.0.0 | 766 | 7/11/2022 |
V2.0.1:
- Updated NuGet dependencies to latest stable versions (November 2025)
- Microsoft.Azure.Kusto.Ingest: 13.0.2 → 14.0.2
- Serilog: 4.2.0 → 4.3.0
- Serilog.Extensions.Logging: 9.0.2 → 9.0.3
- Microsoft.NET.Test.Sdk: 17.8.0 → 17.12.0
- xunit: 2.6.6 → 2.9.3
- xunit.runner.visualstudio: 2.5.6 → 2.8.2
- coverlet.collector: 6.0.0 → 6.0.2
- Serilog.Sinks.File: 7.0.0 → 6.0.0
- System.* packages updated to 9.0.1 for .NET 8.0
V2.0.0:
- Added multi-target framework support for .NET 6.0, .NET 8.0, and .NET 9.0
- Updated dependencies and improved compatibility
- Enhanced CI/CD pipeline with test matrix for both .NET versions
Previous releases:
- Added GZip compression when sending data
- Improved options default values
- Added durability to the Azure Data Explorer Sink
- Added Sample project
- Added unit Tests
- Added End To End Test cases