ToolsToLive.Logging
10.0.2
dotnet add package ToolsToLive.Logging --version 10.0.2
NuGet\Install-Package ToolsToLive.Logging -Version 10.0.2
<PackageReference Include="ToolsToLive.Logging" Version="10.0.2" />
<PackageVersion Include="ToolsToLive.Logging" Version="10.0.2" />
<PackageReference Include="ToolsToLive.Logging" />
paket add ToolsToLive.Logging --version 10.0.2
#r "nuget: ToolsToLive.Logging, 10.0.2"
#:package ToolsToLive.Logging@10.0.2
#addin nuget:?package=ToolsToLive.Logging&version=10.0.2
#tool nuget:?package=ToolsToLive.Logging&version=10.0.2
ToolsToLive.Logging
versioning: 10.2.4, where
- 10 supported .Net version
- 2 library major version
- 4 library minor version
Configuration example
{
"LogsSettings": {
"ApplicationName": "AppName",
"MinimumLevel": "Information",
"NamespaceMinimumLevels": [
{
"Namespace": "Microsoft",
"MinimumLevel": "Warning"
}
],
"ConsoleSinkSettings": {
"Enabled": true,
"RestrictedToMinimumLevel": "Warning",
"Format": "Text"
},
"FileSinkSettings": {
"Enabled": false,
"Path": "logfiles/mylog_.log",
"Format": "Json"
},
"HttpSinkSettings": {
"Enabled": false,
"RequestUri": ""
},
"ElasticSinkSettings": {
"Enabled": false,
"RequestUri": "http://elasticsearch:9200",
"IgnoreCertificateValidation": true,
"UserName": "elastic",
"Password": "*************"
}
}
}
A complete example with every setting is in config.example.json.
Output format
Format of the console and file sinks:
Text(default) — text rendered byOutputTemplateor the built-in template.Json— one line of compact JSON (CLEF) per event, written byRenderedCompactJsonFormatterfromSerilog.Formatting.Compact.OutputTemplateis ignored. A multi-line exception stays inside one line, so a container log collector keeps the event as a single record.
The fields of a JSON event:
| Field | Value |
|---|---|
@t |
Timestamp, ISO 8601 in UTC |
@m |
Rendered message |
@i |
Event id: hash of the message template |
@l |
Level; omitted for Information |
@x |
Exception with stack trace, if any |
@tr, @sp |
Trace id and span id of Activity.Current when the event was written, if any |
| other | Event properties: template values, SourceContext, log context and scopes (RequestId in ASP.NET Core), ThreadId, MachineName, Application |
Unlike {Message:lj} of the text templates, @m puts string values in quotes: User "John" signed in. A template that already quotes a placeholder gets doubled quotes. Numbers and dates in @m use the invariant culture, as in the text output. The values themselves are also written as separate properties.
The file sink keeps buffering, daily rolling and the retention limit in both formats.
Elasticsearch sink
Elastic.Serilog.Sinks 9.0.0 requires Elastic Stack 8.15.0 or later.
By default the sink creates its index templates at start, and the application does not start if Elasticsearch is unavailable. Three settings of ElasticSinkSettings make the application independent of it:
| Setting | Value |
|---|---|
BootstrapMethod |
Failure (default) creates the templates and throws if it cannot; Silent tries to create them and ignores a failure, but still holds the start for up to two request timeouts; None makes no call at start, so the data stream gets the templates that already exist in Elasticsearch. |
RequestTimeout |
Time limit of a request, e.g. 00:00:05. Unset keeps the default of the transport, and a hung Elasticsearch holds each batch for that long. |
FallbackToConsole |
true writes events the sink could not deliver to the console as one line of compact JSON each, whatever the console sink is set to. Default is false: those events are lost. |
FallbackToConsole covers a batch Elasticsearch did not take: no connection, a timeout, a rejected login, retries used up. A single document Elasticsearch rejected inside an accepted batch, such as on a field type conflict, is not a delivery failure and does not reach the console.
A user with BootstrapMethod: None needs the cluster privilege monitor and the index privileges create_doc and auto_configure on logs-generic-*. Without the cluster privilege nothing reaches Elasticsearch.
How to use
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, loggerConfiguration) =>
{
loggerConfiguration.ConfigureLogging(context.Configuration.GetSection("LogsSettings"));
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Elastic.Serilog.Sinks (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Formatting.Compact (>= 3.0.0)
- Serilog.Sinks.Http (>= 9.2.1)
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 |
|---|---|---|
| 10.0.2 | 0 | 11/13/2026 |
| 10.0.1 | 109 | 11/5/2026 |
| 10.0.0 | 115 | 10/26/2026 |
| 10.0.0-alpha.12 | 121 | 2/9/2026 |
| 1.1.0-alpha.10 | 89 | 2/9/2026 |
| 1.0.1 | 926 | 3/20/2022 |
| 1.0.1-alpha.2 | 298 | 3/17/2022 |