SeqLoggerProvider 2.1.2

.NET Standard 2.0
dotnet add package SeqLoggerProvider --version 2.1.2
NuGet\Install-Package SeqLoggerProvider -Version 2.1.2
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="SeqLoggerProvider" Version="2.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SeqLoggerProvider --version 2.1.2
#r "nuget: SeqLoggerProvider, 2.1.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SeqLoggerProvider as a Cake Addin
#addin nuget:?package=SeqLoggerProvider&version=2.1.2

// Install SeqLoggerProvider as a Cake Tool
#tool nuget:?package=SeqLoggerProvider&version=2.1.2

SeqLoggerProvider

License Continuous Deployment NuGet

An implementation of ILoggerProvider, from the .NET Extensions Logging Framework framework, for writing log entries to a Seq server.

This library provides an alternative to the official Seq logger provider, with a goal of providing a slimmer and more extensible implementation. This library includes the following key features that separate it from the official one:

  • Includes only first-party and .NET dependencies, including... -- System.Text.Json, -- System.Threading.Channels, -- Microsoft.Extensions.Http, -- Microsoft.Extensions.Configuration -- Microsoft.Extensions.DependencyInjection
  • Allows for global-scope log data, I.E. data fields that are included upon every log event sent to the server.
  • Allows for more granular control of event batching, including both size-based and time-based thresholds, and flood control
  • Provides extension points for JSON serialization, based on System.Text.Json, allowing for consumers to write custom serializers for log entries that can optimize for performance or data size.
  • Provides extension points for HTTP transmission, allowing for consumers to apply any custom configurations to the HttpClient instances that are used to deliver log entries to the Seq server.

Usage

Basic Setup

To setup the logger provider within a .NET application, simply call the setup method, while setting up your logging system. Either upon your IHostBuilder...

.ConfigureLogging(builder => builder
    .AddSeq())

...or upon your IServiceCollection...

.AddLogging(builder => builder
    .AddSeq());

Configuration

Configuration is automatically extracted from the ambient IConfiguration system, if present, in the same fashion as all first-party logger providers. For example, if you're using an appsettings.json file...

{
  "Logging": {
    "Seq": {
      "ServerUrl": "http://localhost:5341/"
      "ApiKey": "...",
      "GlobalScopeState": {
        "Application": "SeqLogger.Test"
      },
      "LogLevel": {
        "Default": "Debug",
        "SeqLoggerProvider": "None"
      }
    }
  }
}

If you would like to customize the configuration manually, the .AddSeq() method supports a standard configuration delegate being passed in...

builder.AddSeq(options =>
{
	var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
	if (assemblyVersion is not null)
        options.GlobalScopeState.Add("Version", assemblyVersion.ToString();
});

All configuration properties are optional, except for ServerUrl, for obvious reasons.

JSON Customization

In order to customize JSON serialization behavior, simply supply an options configuration delegate, when adding the provider.

builder.AddSeq(configureJsonSerializer: options =>
{
    options.Converters.Add(new MyJsonConverter());
    options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});

HTTP Customization

In order to customize HTTP transmission behavior, simply use the configureHttpClient parameter supported by the .AddSeq() method:

builder.AddSeq(configureHttpClient: builder => builder
    .RedactLoggedHeaders(new[] { SeqLoggerConstants.ApiKeyHeaderName }));
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
2.1.2 213 10/22/2021
2.1.1 199 9/16/2021
2.1.0 192 9/5/2021
2.0.0 227 9/5/2021
1.0.1 190 8/18/2021
1.0.0 186 8/18/2021

Implemented serialization of large numeric values to string, instead of JSON number, as a workaround for https://github.com/datalust/seq-tickets/issues/216
     Updated to latest PATCH version, for all dependencies.