SeqLoggerProvider 2.1.2
dotnet add package SeqLoggerProvider --version 2.1.2
NuGet\Install-Package SeqLoggerProvider -Version 2.1.2
<PackageReference Include="SeqLoggerProvider" Version="2.1.2" />
paket add SeqLoggerProvider --version 2.1.2
#r "nuget: SeqLoggerProvider, 2.1.2"
// 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
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 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 5.0.0)
- Microsoft.Extensions.ObjectPool (>= 5.0.11)
- Microsoft.Extensions.Options.DataAnnotations (>= 5.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 5.0.2)
- System.Threading.Channels (>= 5.0.0)
-
.NETStandard 2.1
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 5.0.0)
- Microsoft.Extensions.ObjectPool (>= 5.0.11)
- Microsoft.Extensions.Options.DataAnnotations (>= 5.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 5.0.2)
- System.Threading.Channels (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.