ToolsToLive.Logging 10.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ToolsToLive.Logging --version 10.0.1
                    
NuGet\Install-Package ToolsToLive.Logging -Version 10.0.1
                    
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="ToolsToLive.Logging" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ToolsToLive.Logging" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ToolsToLive.Logging" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ToolsToLive.Logging --version 10.0.1
                    
#r "nuget: ToolsToLive.Logging, 10.0.1"
                    
#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.
#:package ToolsToLive.Logging@10.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ToolsToLive.Logging&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ToolsToLive.Logging&version=10.0.1
                    
Install as a Cake Tool

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 by OutputTemplate or the built-in template.
  • Json — one line of compact JSON (CLEF) per event, written by RenderedCompactJsonFormatter from Serilog.Formatting.Compact. OutputTemplate is 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

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