Serilog.Sinks.AzureTableStorage
11.0.0
dotnet add package Serilog.Sinks.AzureTableStorage --version 11.0.0
NuGet\Install-Package Serilog.Sinks.AzureTableStorage -Version 11.0.0
<PackageReference Include="Serilog.Sinks.AzureTableStorage" Version="11.0.0" />
<PackageVersion Include="Serilog.Sinks.AzureTableStorage" Version="11.0.0" />
<PackageReference Include="Serilog.Sinks.AzureTableStorage" />
paket add Serilog.Sinks.AzureTableStorage --version 11.0.0
#r "nuget: Serilog.Sinks.AzureTableStorage, 11.0.0"
#:package Serilog.Sinks.AzureTableStorage@11.0.0
#addin nuget:?package=Serilog.Sinks.AzureTableStorage&version=11.0.0
#tool nuget:?package=Serilog.Sinks.AzureTableStorage&version=11.0.0
Serilog.Sinks.AzureTableStorage 
Writes to a table in Azure Table Storage.
Package - Serilog.Sinks.AzureTableStorage | Platforms - .NET Standard 2.0
var log = new LoggerConfiguration()
.WriteTo.AzureTableStorage("<connectionString>")
.CreateLogger();
Configuration
| Configuration | Description | Default |
|---|---|---|
| connectionString | The Cloud Storage Account connection string | |
| sharedAccessSignature | The storage account/table SAS key | |
| accountName | The storage account name | |
| restrictedToMinimumLevel | The minimum log event level required in order to write an event to the sink. | Verbose |
| formatProvider | Culture-specific formatting information | |
| storageTableName | Table name that log entries will be written to | LogEvent |
| batchPostingLimit | The maximum number of events to post in a single batch | 100 |
| period | The time to wait between checking for event batches | 0:0:2 |
| keyGenerator | The key generator used to create the PartitionKey and the RowKey for each log entry | DefaultKeyGenerator |
| propertyColumns | Specific log event properties to be written as table columns | |
| bypassTableCreationValidation | Bypass the exception in case the table creation fails | false |
| documentFactory | Provider to create table document from LogEvent | DefaultDocumentFactory |
| tableClientFactory | Provider to create table client | DefaultTableClientFactory |
| partitionKeyRounding | Partition key rounding time span | 0:5:0 |
JSON configuration
It is possible to configure the sink using Serilog.Settings.Configuration by specifying the table name and connection string in appsettings.json:
"Serilog": {
"WriteTo": [
{"Name": "AzureTableStorage", "Args": {"storageTableName": "", "connectionString": ""}}
]
}
JSON configuration must be enabled using ReadFrom.Configuration(); see the documentation of the JSON configuration package for details.
XML <appSettings> configuration
To use the file sink with the Serilog.Settings.AppSettings package, first install that package if you haven't already done so:
Install-Package Serilog.Settings.AppSettings
Instead of configuring the logger in code, call ReadFrom.AppSettings():
var log = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
In your application's App.config or Web.config file, specify the file sink assembly and required path format under the <appSettings> node:
<configuration>
<appSettings>
<add key="serilog:using:AzureTableStorage" value="Serilog.Sinks.AzureTableStorage" />
<add key="serilog:write-to:AzureTableStorage.connectionString" value="DefaultEndpointsProtocol=https;AccountName=ACCOUNT_NAME;AccountKey=KEY;EndpointSuffix=core.windows.net" />
<add key="serilog:write-to:AzureTableStorage.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
</appSettings>
</configuration>
Example Configuration for ASP.NET
public static class Program
{
private const string OutputTemplate = "{Timestamp:HH:mm:ss.fff} [{Level:u1}] {Message:lj}{NewLine}{Exception}";
public static async Task<int> Main(string[] args)
{
// azure home directory
var homeDirectory = Environment.GetEnvironmentVariable("HOME") ?? ".";
var logDirectory = Path.Combine(homeDirectory, "LogFiles");
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: OutputTemplate)
.WriteTo.File(
path: $"{logDirectory}/boot.txt",
rollingInterval: RollingInterval.Day,
shared: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
outputTemplate: OutputTemplate,
retainedFileCountLimit: 10
)
.CreateBootstrapLogger();
try
{
Log.Information("Starting web host");
var builder = Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(args);
builder.Host
.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.Enrich.WithProperty("ApplicationName", builder.Environment.ApplicationName)
.Enrich.WithProperty("EnvironmentName", builder.Environment.EnvironmentName)
.WriteTo.Console(outputTemplate: OutputTemplate)
.WriteTo.File(
path: $"{logDirectory}/log.txt",
rollingInterval: RollingInterval.Day,
shared: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
outputTemplate: OutputTemplate,
retainedFileCountLimit: 10
)
.WriteTo.AzureTableStorage(
connectionString: context.Configuration.GetConnectionString("StorageAccount"),
propertyColumns: new[] { "SourceContext", "RequestId", "RequestPath", "ConnectionId", "ApplicationName", "EnvironmentName" }
)
);
ConfigureServices(builder);
var app = builder.Build();
ConfigureMiddleware(app);
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}
}
private static void ConfigureServices(WebApplicationBuilder builder)
{
}
private static void ConfigureMiddleware(Microsoft.AspNetCore.Builder.WebApplication app)
{
}
}
Example: Using DefaultAzureCredential
To use Azure Managed Identity or other Azure SDK credential flows with this sink, you can provide an existing TableServiceClient instance constructed with DefaultAzureCredential. This is especially useful for Azure-hosted environments where connection strings are discouraged.
using Azure.Data.Tables;
using Azure.Identity;
using Serilog;
// Replace with your actual Azure Table Storage endpoint
string tableEndpoint = "https://yourstorageaccountname.table.core.windows.net/";
// Create DefaultAzureCredential
var credential = new DefaultAzureCredential();
// Create TableServiceClient with the endpoint and credential
var tableServiceClient = new TableServiceClient(new Uri(tableEndpoint), credential);
// Configure Serilog to use the TableServiceClient
var log = new LoggerConfiguration()
.WriteTo.AzureTableStorage(
tableServiceClient: tableServiceClient,
storageTableName: "LogEvent"
// [other options as desired]
)
.CreateLogger();
Note:
TheAzureTableStoragesink will use the providedTableServiceClientfor all operations.
TheDefaultAzureCredentialwill automatically select the most appropriate authentication mechanism depending on your environment: Azure Managed Identity, Visual Studio sign-on, Azure CLI, etc.
Change Log
10.0.0
- Breaking: writeInBatches removed, all writes are now batched
- Update: update to serilog 4.0
- Remove: removed dependance on Serilog.Sinks.PeriodicBatching, use serilog 4.0
IBatchedLogEventSink
9.6.0
- Fix: improve timezone support
9.5.0
- Add: use ULID for rowkey for speed and efficiency
9.4.0
- Fix: prevent duplicate rowkey
9.1.0
- Add: Built-in trace and span id support
9.0.0
- Breaking: Due to issue with creating provides from configuration
IDocumentFactory.Createadd AzureTableStorageSinkOptions and IKeyGenerator argumentsIKeyGenerator.GeneratePartitionKeyadd AzureTableStorageSinkOptions argumentIKeyGenerator.GenerateRowKeyadd AzureTableStorageSinkOptions argument
- Fix: DefaultDocumentFactory and DefaultKeyGenerator needed paramaterless contructor for use in configuration files
- Add: ITableClientFactory to control TableClient creation
8.5.0
- Add option for partition key rounding
- Move IKeyGenertor from options
- Add DateTime extension methods for partition key and row key
- Add sample web project
8.0.0
- Breaking: major refactor to simplify code base
- Removed: AzureTableStorageWithProperties extension removed, use equivalent AzureTableStorage
- Removed: ICloudTableProvider provider removed
- Added: IDocumentFactory to allow control over table document
- Change: PartitionKey and RowKey changed to new implementation
7.0.0
- Update dependencies: repace Microsoft.Azure.Cosmos.Table with Azure.Data.Tables
6.0.0
- Updated dependencies: replace deprecated package WindowsAzure.Storage with Microsoft.Azure.Cosmos.Table 1.0.8
- Updated dependencies: Serilog 2.10.0
5.0.0
- Migrated to new CSPROJ project system
- Updated dependencies: WindowsAzure.Storage 8.6.0, Serilog 2.6.0, Serilog.Sinks.PeriodicBatching 2.1.1
- Fix #36 - Allow using SAS URI for logging.
1.5
- Moved from serilog/serilog
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .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 is compatible. |
| .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. |
-
.NETStandard 2.0
- Azure.Data.Tables (>= 12.13.0)
- Serilog (>= 4.4.0)
- ulid (>= 1.4.1)
-
.NETStandard 2.1
- Azure.Data.Tables (>= 12.13.0)
- Serilog (>= 4.4.0)
- ulid (>= 1.4.1)
-
net10.0
- Azure.Data.Tables (>= 12.13.0)
- Serilog (>= 4.4.0)
- ulid (>= 1.4.1)
-
net11.0
- Azure.Data.Tables (>= 12.13.0)
- Serilog (>= 4.4.0)
- ulid (>= 1.4.1)
-
net8.0
- Azure.Data.Tables (>= 12.13.0)
- Serilog (>= 4.4.0)
- ulid (>= 1.4.1)
NuGet packages (12)
Showing the top 5 NuGet packages that depend on Serilog.Sinks.AzureTableStorage:
| Package | Downloads |
|---|---|
|
TouchConvert.Tenant.Api.V1.Dtos
Data transfer objects for TouchConvert version one APIs. |
|
|
TouchConvert.Tenant.Api.V2.Dtos
Data transfer objects for TouchConvert version two APIs. |
|
|
Indiko.Blocks.Logging.Serilog
Building Blocks Logging Serilog |
|
|
BumperLane.Hosted.Api.V2.Application
BumperLane Core API functionality |
|
|
AzureWebFarm.OctopusDeploy
Scalable, OctopusDeploy-powered webfarm using Windows Azure Web Roles. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0 | 0 | 11/12/2026 |
| 10.2.0 | 442,807 | 8/28/2025 |
| 10.1.0 | 318,533 | 1/16/2025 |
| 10.0.2 | 125,384 | 10/26/2024 |
| 10.0.1 | 176,004 | 7/26/2024 |
| 10.0.0 | 32,975 | 7/10/2024 |
| 10.0.0-beta.1 | 2,336 | 6/3/2024 |
| 9.7.1 | 176,540 | 5/29/2024 |
| 9.7.0 | 18,523 | 5/10/2024 |
| 9.6.0 | 71,293 | 4/26/2024 |
| 9.5.0 | 50,037 | 4/10/2024 |
| 9.4.1 | 47,947 | 3/10/2024 |
| 9.3.0 | 5,046 | 3/6/2024 |
| 9.2.0 | 151,840 | 12/11/2023 |
| 9.1.0 | 36,945 | 11/9/2023 |
| 9.0.0 | 122,156 | 8/6/2023 |
| 9.0.0-beta.2 | 285 | 8/1/2023 |
| 9.0.0-beta.1.1 | 294 | 8/1/2023 |
| 8.5.42-alpha.0.7 | 290 | 8/1/2023 |
| 8.5.41 | 50,997 | 6/24/2023 |