![]() |
VOOZH | about |
dotnet add package Serilog.Sinks.Logz.Io --version 8.0.0
NuGet\Install-Package Serilog.Sinks.Logz.Io -Version 8.0.0
<PackageReference Include="Serilog.Sinks.Logz.Io" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.Logz.Io" Version="8.0.0" />Directory.Packages.props
<PackageReference Include="Serilog.Sinks.Logz.Io" />Project file
paket add Serilog.Sinks.Logz.Io --version 8.0.0
#r "nuget: Serilog.Sinks.Logz.Io, 8.0.0"
#:package Serilog.Sinks.Logz.Io@8.0.0
#addin nuget:?package=Serilog.Sinks.Logz.Io&version=8.0.0Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.Logz.Io&version=8.0.0Install as a Cake Tool
👁 NuGet Version
👁 NuGet
👁 Documentation
👁 Join the chat at https://gitter.im/serilog/serilog
👁 Help
Package - Serilog.Sinks.Logz.Io | Platforms - NET8.0, .NET Standard 2.0, .NET 4.6.2
v7 has breaking changes.
So now instead of doing:
"bufferPathFormat": "Buffer-{Hour}.json",
need to change config file to:
"bufferBaseFileName": "Buffer",
"bufferRollingInterval": "Hour",
So now instead of doing:
"useHttps": true,
"dataCenterSubDomain": "listener",
"port": null
need to change config file to:
"dataCenter": {
"useHttps": true,
"dataCenterSubDomain": "listener",
"port": null
}
For more information see: https://github.com/FantasticFiasco/serilog-sinks-http/releases/tag/v8.0.0
If you want to include the HTTP sink in your project, you can install it directly from NuGet.
To install the sink, run the following command in the Package Manager Console:
PM> Install-Package Serilog.Sinks.Logz.Io
This package has been deprecated as it is legacy and is no longer maintained. Please update to Serilog.Sinks.Logz.Io. Latest version contains exact the same functionality and extension methods to configure loggers.
In the following example, the sink will POST log events to https://listener-eu.logz.io:8071/?type=app&token=<token> over HTTP. We configure the sink using named arguments instead of positional because historically we've seen that most breaking changes where the result of a new parameter describing a new feature. Using named arguments means that you more often than not can migrate to new major versions without any changes to your code.
Used in conjunction with Serilog.Settings.Configuration the same sink can be configured in the following way:
{
"Serilog": {
"MinimumLevel": "Warning",
"WriteTo": [
{
"Name": "LogzIoDurableHttp",
"Args": {
"requestUri": "https://listener-eu.logz.io:8071/?type=app&token=<token>"
}
}
]
}
}
The sink will be configured as durable, i.e. log events are persisted on disk before being sent over the network, thus protected against data loss after a system or process restart. For more information please read the wiki.
Library depends on a fantastic Serilog.Sinks.Http package which allows to create buffered files and controls HTTP uploads.
Here we are using DurableHttpUsingTimeRolledBuffers extension method to configure durable HTTP sink.
See: DurableHttpUsingTimeRolledBuffers
Wiki: Durable time rolled HTTP sink
Library is using Newtonsoft.Json package for serialization. However it is possible to change/configure serialization behavior using LogzIoSerializer.Instance property. This instance should be configured at application startup (best if it happens before Serilog configuration).
Default behavior which is set automatically:
LogzIoSerializer.Instance = new LogzIoSerializer(LogzIoTextFormatterFieldNaming.CamelCase, false);
You can also set custom JsonSerializerSettings using following code:
LogzIoSerializer.Instance.WithSerializerSettings(customSetttings);
Of course you can override complete serialization logic by implementing ILogzIoSerializer interface and configuring your own implementation.
Newtonsoft.JSON package which is used to serialize log entries is also able to serialize lamdbas, delegates and similar functional constructs which normally does not make sense to have in logs. It also might produce huge blobs with assembly information thus increasing log entry size to unacceptable sizes.
In order to handle this issue MulticastDelegate type serialization is overriden using custom JsonConverter.
If you still want to enable this behavior - at application startup you can configure package serializer using following code:
LogzIoSerializer.Instance = new LogzIoSerializer(LogzIoTextFormatterFieldNaming.CamelCase, false);
NOTE: in example bellow only
requestUriis required. All other properties represents default values.
{
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft.AspNetCore": "Debug"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"WriteTo": [
{
"Name": "LogzIoDurableHttp",
"Args": {
"requestUri": "https://listener-eu.logz.io:8071/?type=app&token=<token>",
"bufferBaseFileName": "Buffer",
"bufferRollingInterval": "Day",
"bufferFileSizeLimitBytes": "104857600",
"bufferFileShared": false,
"retainedBufferFileCountLimit": 31,
"logEventsInBatchLimit": 1000,
"period": null,
"restrictedToMinimumLevel": "Minimum",
"logzioTextFormatterOptions": {
"BoostProperties": true,
"LowercaseLevel": true,
"IncludeMessageTemplate": true,
"FieldNaming": "CamelCase",
"EventSizeLimitBytes": 261120
}
}
}
]
}
}
In the example above logzIo formatter options are default, there is no need to specify these if it fits your needs.
configuration
.WriteTo.LogzIoDurableHttp(
"https://listener-eu.logz.io:8071/?type=app&token=<token>",
logzioTextFormatterOptions: new LogzioTextFormatterOptions
{
BoostProperties = true,
LowercaseLevel = true,
IncludeMessageTemplate = true,
FieldNaming = LogzIoTextFormatterFieldNaming.CamelCase,
EventSizeLimitBytes = 261120,
})
.MinimumLevel.Verbose();
NOTE: it is strongly recommended to use durable logger. It is much more robust and tollerates various network issues thus your logs won't be lost.
In the following example, the sink will POST log events to https://listener.logz.io over HTTPS.
ILogger log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.LogzIo("<logzio token>", "<log type>", useHttps: true)
.CreateLogger();
log.Information("Logging {@Heartbeat} from {Computer}", heartbeat, computer);
More advanced configuration is also available:
ILogger log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.LogzIo("<logzio token>", "<log type>",
new LogzioOptions
{
RestrictedToMinimumLevel = LogEventLevel.Debug,
Period = TimeSpan.FromSeconds(15),
LogEventsInBatchLimit = 50
})
.CreateLogger();
Alternatively configuration can be done within your appsettings.json file:
{
"Serilog": {
"MinimumLevel": {
"Default": "Verbose"
},
"WriteTo": [
{
"Name": "LogzIo",
"Args": {
"authToken": "<logzio token>",
"type": "<log type>",
"dataCenterSubDomain": "listener",
"dataCenter": {
"subDomain": "listener",
"useHttps": true
},
"logEventsInBatchLimit": 5000,
"period": "00:00:02",
"restrictedToMinimumLevel": "Debug",
"lowercaseLevel": false,
"environment": "",
"serviceName": ""
}
}
]
}
}
See for more details: https://www.elastic.co/guide/en/ecs/current/ecs-reference.html
ILogger log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.LogzIo(new LogzioEcsOptions
{
Type = "<log type>",
AuthToken = "<logzio token>",
DataCenter = new LogzioDataCenter
{
SubDomain = "listener",
Port = 8701,
UseHttps = true
}
},
batchPostingLimit: 50,
period: TimeSpan.FromSeconds(15),
restrictedToMinimumLevel: LogEventLevel.Debug
)
.CreateLogger();
Alternatively configuration can be done within your appsettings.json file, please note CustomEcsTextFormatterConfiguration setup is optional:
{
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.Logz.Io"
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "LogzIoEcs",
"Args": {
"options": {
"type": "<log type>",
"authToken": "<logzio token>"
},
"logEventsInBatchLimit": 30,
"period": "00:00:02",
"restrictedToMinimumLevel": "Debug",
"formatterConfiguration": "Serilog.Sinks.Logz.Io.AspNetCoreApi.Logging.CustomEcsTextFormatterConfiguration, Serilog.Sinks.Logz.Io.AspNetCoreApi"
}
}
]
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on Serilog.Sinks.Logz.Io:
| Package | Downloads |
|---|---|
|
AllbatrossLogger
Package Description |
|
|
AlbaLogger
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.0.0 | 88,430 | 8/6/2025 |
| 7.2.0 | 714,354 | 12/12/2022 |
| 7.1.0 | 87,795 | 10/12/2022 |
| 7.0.0 | 11,171 | 10/12/2022 |
| 6.0.0 | 709,497 | 11/14/2021 |
| 5.1.0 | 27,288 | 10/2/2021 |
| 5.0.0 | 31,964 | 9/25/2021 |
| 3.0.1 | 111,298 | 2/9/2021 |
| 3.0.0 | 4,794 | 2/9/2021 |
| 2.3.0 | 111,422 | 10/30/2020 |
| 2.2.3 | 14,906 | 10/1/2020 |
| 2.2.2 | 95,763 | 4/16/2020 |
| 2.2.1 | 101,907 | 12/26/2018 |
| 2.2.0 | 6,745 | 12/20/2018 |
| 2.1.2 | 5,423 | 12/17/2018 |
| 2.1.1 | 8,452 | 10/17/2018 |
| 2.1.1-alpha.1 | 727 | 10/16/2018 |
| 2.1.0 | 5,042 | 10/10/2018 |
| 2.0.0 | 10,206 | 5/21/2018 |
| 1.2.4 | 5,590 | 5/16/2018 |
Upgrade dependencies