![]() |
VOOZH | about |
dotnet add package Serilog.Sinks.InfluxDB.Syslog --version 2.3.6
NuGet\Install-Package Serilog.Sinks.InfluxDB.Syslog -Version 2.3.6
<PackageReference Include="Serilog.Sinks.InfluxDB.Syslog" Version="2.3.6" />
<PackageVersion Include="Serilog.Sinks.InfluxDB.Syslog" Version="2.3.6" />Directory.Packages.props
<PackageReference Include="Serilog.Sinks.InfluxDB.Syslog" />Project file
paket add Serilog.Sinks.InfluxDB.Syslog --version 2.3.6
#r "nuget: Serilog.Sinks.InfluxDB.Syslog, 2.3.6"
#:package Serilog.Sinks.InfluxDB.Syslog@2.3.6
#addin nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.6Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.6Install as a Cake Tool
A serilog sink that writes events to InfluxDB in syslog message format (by default) as described on the Influx blog. The exact fields, tags and even measurement names can be customised via the sink configuration, as outlined below.
Supports platforms compatible with the .NET Platform Standard netstandard2.0.
Compatible only with InfluxDB v2.0 and upwards
Warning: use for InfluxDB v1.X following nuget package : 👁 nuget
for V1 see Get Started for V1.X
To get started install the Serilog.Sinks.InfluxDB.Syslog package:
PM> Install-Package Serilog.Sinks.InfluxDB.Syslog
OR
$ dotnet add package Serilog.Sinks.InfluxDB.Syslog
If running locally for development purpose, you can use docker-compose-v2.yml at root of this repository and adapt volumes if needed
$ docker-compose -f docker-compose-v2.yml up -d
Point the logger to InfluxDb (quickest way using default _internal database):
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(applicationName: "Quick test",
uri: new Uri("http://127.0.0.1:8086"),
organizationId: "88e1f5a5ad074d9e", // Organization Id - unique id can be found under Profile > About > Common Ids)
bucketName: "logs",
token: "bGfBKhSycNiUOia4k7peib2jHFewkz3o6Hv2uz1xAoUcdnEFRW7cHn03KICySLemA4VPZKvc0CwzSQT8GNl2DA==")
.CreateLogger();
Another sample using InfluxDBSinkOptions for more control over periodic batching options and connection information:
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(new InfluxDBSinkOptions()
{
ApplicationName = "fluentSample",
InstanceName = "fluentSampleInstance",
ConnectionInfo = new InfluxDBConnectionInfo()
{
Uri = new Uri("http://127.0.0.1:8086"),
BucketName = "logs",
OrganizationId = "88e1f5a5ad074d9e", // Organization Id - unique id can be found under Profile > About > Common Ids
// To be set if bucket already created and give write permission and set CreateBucketIfNotExists to false
Token = null,
CreateBucketIfNotExists = true,
//To specify if Bucket needs to be created and if token not known or without all access permissions
AllAccessToken = "bGfBKhSycNiUOia4k7peib2jHFewkz3o6Hv2uz1xAoUcdnEFRW7cHn03KICySLemA4VPZKvc0CwzSQT8GNl2DA==",
BucketRetentionPeriod = TimeSpan.FromDays(1)
},
BatchOptions = new PeriodicBatching.PeriodicBatchingSinkOptions()
{
BatchSizeLimit = 50,
Period = TimeSpan.FromSeconds(10),
EagerlyEmitFirstEvent = true,
QueueLimit = null
}
})
.CreateLogger();
If using appsettings.json for configuration the following example illustrates using InfluxDb and Console sinks.
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.InfluxDB.Syslog"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo:Influx": {
"Name": "InfluxDB",
"Args": {
"sinkOptions": {
"ApplicationName": "testApp",
"InstanceName": "testInstance",
"ConnectionInfo": {
"Uri": "http://localhost:8086",
"BucketName": "logs",
"OrganizationId": "88e1f5a5ad074d9e",
"Token": "edBlcWgLkoPOituD_6V1ftCznpDR8niFcF46MJCSYuSxc1FM_srm9cuoc84yX5kOjOH_11Zvxk_juqr44S-57A==",
"CreateBucketIfNotExists": false
//"Username": "influxdbroot",
//"Password": "TBD"
"BucketRetentionPeriod": "7.00:00:00",
},
"BatchOptions": {
"EagerlyEmitFirstEvent": true,
"BatchSizeLimit": 100,
"Period": "0.00:00:30",
"QueueLimit": 1000000
}
}
}
},
"Properties": {
"Application": "Serilog Sink InfluxDb Console Sample"
}
}
}
All those samples can be found under project subdirectory samples of this repository.
"sinkOptions": {
"MeasurementName": "syslog",
"ApplicationName": "testApp",
"InstanceName": "testInstance",
"IncludeFullException": true,
"IncludeHostname": false,
"IncludeLevel": true,
"IncludeSeverity": true,
"IncludeDefaultFields": true,
"ExtendedFields": ["ReleaseNumber"],
"ExtendedTags": [],
...
}
Since initial creation of this plugin, InfluxDB now supports a more flexible logging approach that eliminates the strict requirement of the syslog format. This means it's possible to create leaner logging payloads without the additional syslog-specific entries with a configuration such as the following:
"sinkOptions": {
"MeasurementName": "mymeasurement",
"IncludeHostname": false,
"IncludeLevel": false,
"IncludeSeverity": false,
"IncludeDefaultFields": false,
...
}
This configuration will produce a log entry with only a message and time:
[
{
Time: DateTime_1,
Field: message,
Value: Some warning "Some parameter",
Tags: {}
}
]
**For InfluxDB v1.X use following nuget package 😗* 👁 nuget
PM> Install-Package Serilog.Sinks.InfluxDBV1.Syslog -Version 1.3.1
OR
$ dotnet add package Serilog.Sinks.InfluxDBV1.Syslog --version 1.3.1
If running locally for development purpose, you can use docker-compose.yml at root of this repository and adapt volumes if needed
$ docker-compose -f docker-compose.yml up -d
Point the logger to InfluxDb (quickest way using default _internal database):
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(
applicationName: "Quick Test",
uri : new Uri("http://127.0.0.1:8086"));
Another sample using InfluxDBSinkOptions for more control over periodic batching options and connection information:
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(new InfluxDBSinkOptions()
{
ApplicationName = "fluentSample", // Application Name
InstanceName = "fluentSampleInstance", // Instance or Environment Name
ConnectionInfo = new InfluxDBConnectionInfo() // Connection Details
{
Uri = new Uri("http://127.0.0.1:8086"),
DbName = "_internal",
},
BatchOptions = new PeriodicBatching.PeriodicBatchingSinkOptions()
{
BatchSizeLimit = 50,
Period = TimeSpan.FromSeconds(10),
EagerlyEmitFirstEvent = true,
QueueLimit = null
}
})
.CreateLogger();
If using appsettings.json for configuration the following example illustrates using InfluxDb and Console sinks.
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.InfluxDBV1.Syslog"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "InfluxDB",
"Args": {
"sinkOptions": {
"applicationName": "testApp",
"instanceName": "testInstance",
"ConnectionInfo": {
"Uri": "http://localhost:8086",
"DbName": "_internal",
"Username": "",
"Password": ""
},
"BatchOptions": {
"EagerlyEmitFirstEvent": true,
"BatchSizeLimit": 200,
"Period": "0.00:00:30",
"QueueLimit": null
}
}
}
}
],
"Properties": {
"Application": "Serilog Sink InfluxDb Console Sample"
}
}
}
👁 Latest Release
👁 Latest Pre-Release
👁 Downloads
| Branch | Status |
|---|---|
| Main Branch | 👁 Build |
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-2640M CPU 2.80GHz (Sandy Bridge), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=5.0.101
[Host] : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT
| Method | N | Mean | Error | StdDev |
|---|---|---|---|---|
| LogSomething | 1000 | 5.781 us | 0.1832 us | 0.5315 us |
Nothing showed up, what can I do?
If events don't appear in InfluxDb after looking in corresponding database via Chronograf, Grafana or else. Either your application was unable to contact the InfluxDb server, or else the InfluxDb server rejected the log events for some reason.
The InfluxDb server may reject incoming events if they're missing required credentials (check troubleshoot articles on influxdb, if the payload is corrupted somehow, or if the log events are too large to accept.
If there's no information in the ingestion log, the application was probably unable to reach the server because of network configuration or connectivity issues. These are reported to the application through Serilog's SelfLog.
Add the following line after the logger is configured to print any error information to the console:
Serilog.Debugging.SelfLog.Enable(Console.Error);
If the console is not available, you can pass a delegate into SelfLog.Enable() that will be called with each error message:
Serilog.Debugging.SelfLog.Enable(message => {
// Do something with `message`
});
| 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 was computed. 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 was computed. 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. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.6 | 8,065 | 12/8/2024 |
| 2.3.5 | 22,098 | 10/27/2023 |
| 2.3.4 | 3,160 | 7/18/2023 |
| 2.3.3 | 2,432 | 1/30/2023 |
| 2.3.2 | 1,139 | 1/11/2023 |
| 2.3.1 | 543 | 1/11/2023 |
| 2.3.0 | 573 | 1/8/2023 |
| 2.2.0 | 2,024 | 8/20/2022 |
| 2.1.2 | 579 | 8/13/2022 |
| 2.1.1 | 5,945 | 3/8/2022 |
| 2.1.0 | 12,749 | 12/12/2021 |
| 2.0.3 | 578 | 12/5/2021 |
| 2.0.2 | 2,431 | 6/19/2021 |
| 2.0.1 | 1,094 | 3/13/2021 |
| 2.0.0 | 1,104 | 2/13/2021 |
| 1.4.1 | 836 | 3/8/2022 |
| 1.4.0 | 1,356 | 12/12/2021 |
| 1.3.2 | 2,520 | 3/13/2021 |
| 1.3.1 | 3,179 | 1/23/2021 |
| 1.3.0 | 693 | 1/21/2021 |
2.3.6 (only for InfluxDB v2.XX):
- Update nuget dependencies including InfluxDB.Client which use InfluxDBClient constructor instead of InfluxDBClientFactory
- Update test projects to dotnet 9 sdk and add global.json to fix sdk
2.3.5 (only for InfluxDB v2.XX):
- New parameter IncludeDefaultFields default to true to turn off all default fields
- New parameter MeasurementName to allow measurement name to be customised
2.3.4 (only for InfluxDB v2.XX):
- New parameter IncludeHostname default to true
- New parameter IncludeLevel default to true
- New parameter IncludeSeverity default to true
2.3.3:
- **Warning - Use Serilog.Sinks.InfluxDBV1.Syslog nuget for InfluxDB V1.XX**
- Update nuget dependencies including InfluxDB.Client which use InfluxDBClient constructor instead of InfluxDBClientFactory
- Split Serilog.Sinks.InfluxDB.Syslog and Serilog.Sinks.InfluxDBV1.Syslog
2.3.2:
- Revert fix for https://github.com/pada57/serilog-sinks-influxdb/issues/28
2.3.1:
- Fix only CR, LF and \ must be escaped https://github.com/pada57/serilog-sinks-influxdb/issues/26
- Fix non-ASCI characters must be omitted https://github.com/pada57/serilog-sinks-influxdb/issues/28
2.3.0:
- Extended Fields/Tags to support name mapping https://github.com/pada57/serilog-sinks-influxdb/issues/20
- Fix field type ProcId to be string instead of integer as in syslog format https://github.com/pada57/serilog-sinks-influxdb/issues/21
- Fix issue with extended tags which were adding quotes for string https://github.com/pada57/serilog-sinks-influxdb/issues/18
- Make optional application name and instance name https://github.com/pada57/serilog-sinks-influxdb/issues/23
- Update nuget dependencies including InfluxDB.Client and Serilog.Sinks.PeriodicBatching
2.2.0:
- Add support for Extended fields and Extended tags
2.1.2:
- Update nuget dependencies including InfluxDB.Client and Serilog
2.1.1:
- Update nuget dependencies including InfluxDB.Client and Serilog.Sinks.PeriodicBatching
2.1.0 (only for InfluxDB v2.XX):
- New parameter IncludeFullException default to false
- Update nuget dependencies
2.0.3:
- Update nuget dependencies including InfluxDB.Client
2.0.2:
- Update nuget dependencies including InfluxDB.Client
2.0.1:
- Update nuget dependencies including InfluxDB.Client
2.0: Support for InfluxDB v2, not compatible with v1
- Change main dependency from InfluxData.Net to InfluxDB.Client
- Add two authentication mode with Token or Credentials (User/Password)
- Add new BatchOptions to have control over batch size / queue limit / period / eager first event emition
1.4.0 (only for InfluxDB v1.XX):
- New parameter IncludeFullException default to false
- Update nuget dependencies
1.3.2:
- Update nuget dependencies
1.3.1:
- Adapting namespaces
1.3:
- Handling of response with selflog and throwing exceptions letting PeriodicBatchingSink handling backoffs/retries
- Adding single InfluxDBSinkOptions for creating sink, kept backward compatibility for previous extension methods -
- Add Benchmark tests and unit tests
- Add sample projects
- Add documentation and license (MIT)
- Removed unused method
1.2:
- Add instance name and rename source to application name
- Remove tag on message template
- Map facility to instance name
- Remove filtering of logevents and directly escape message after formatting
- Update to Serilog 2.10 and Serilog.Sinks.PeriodicBatching 2.3
1.1:
- Use Uri instead of address/port in extensions methods and also in InfluxDbCOnnectionInfo object
1.0:
- Forked fromhttps://github.com/ThiagoBarradas/serilog-sinks-influxdb
- Adaption for syslog format
- Fix 400 errors due to invalid characters with JSON payload