Serilog.Sinks.InfluxDB.Syslog
2.3.3
See the version list below for details.
dotnet add package Serilog.Sinks.InfluxDB.Syslog --version 2.3.3
NuGet\Install-Package Serilog.Sinks.InfluxDB.Syslog -Version 2.3.3
<PackageReference Include="Serilog.Sinks.InfluxDB.Syslog" Version="2.3.3" />
paket add Serilog.Sinks.InfluxDB.Syslog --version 2.3.3
#r "nuget: Serilog.Sinks.InfluxDB.Syslog, 2.3.3"
// Install Serilog.Sinks.InfluxDB.Syslog as a Cake Addin #addin nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.3 // Install Serilog.Sinks.InfluxDB.Syslog as a Cake Tool #tool nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.3
Serilog.Sinks.InfluxDB.Syslog
A serilog sink that writes events to InfluxDB in syslog message format as described on the Influx blog.
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 :
for V1 see Get Started for V1.X
Getting Started
InfluxDB v2.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.
InfluxDB v1.X
**For InfluxDB v1.X use following nuget package 😗*
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"
}
}
}
Build Status
Branch | Status |
---|---|
Main Branch |
Benchmarks
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 |
Troubleshooting
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.
Server-side issues
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.
Client-side issues
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`
});
Troubleshooting checklist
- Check InfluxDb connectivity and if Server-side issues see section above
- Turn on the Serilog SelfLog as described above to check for connectivity problems and other issues on the client side.
- Make sure your application calls Log.CloseAndFlush(), or disposes the root Logger, before it exits - otherwise, buffered events may be lost.
- If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated "hard" if the close button in the title bar is used, so events buffered for sending to InfluxDb may be lost if you use it.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- InfluxDB.Client (>= 4.10.0)
- Serilog (>= 2.12.0)
- Serilog.Sinks.PeriodicBatching (>= 3.1.0)
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.3.5 | 15,969 | 10/27/2023 |
2.3.4 | 2,994 | 7/18/2023 |
2.3.3 | 2,033 | 1/30/2023 |
2.3.2 | 945 | 1/11/2023 |
2.3.1 | 339 | 1/11/2023 |
2.3.0 | 379 | 1/8/2023 |
2.2.0 | 1,769 | 8/20/2022 |
2.1.2 | 409 | 8/13/2022 |
2.1.1 | 5,361 | 3/8/2022 |
2.1.0 | 12,389 | 12/12/2021 |
2.0.3 | 354 | 12/5/2021 |
2.0.2 | 2,214 | 6/19/2021 |
2.0.1 | 854 | 3/13/2021 |
2.0.0 | 875 | 2/13/2021 |
1.4.1 | 614 | 3/8/2022 |
1.4.0 | 1,122 | 12/12/2021 |
1.3.2 | 2,299 | 3/13/2021 |
1.3.1 | 2,955 | 1/23/2021 |
1.3.0 | 444 | 1/21/2021 |
1.2.0 | 617 | 9/17/2020 |
1.1.0 | 555 | 8/14/2020 |
1.0.0 | 569 | 8/14/2020 |
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