Serilog.Sinks.OpenObserve-KKP 1.0.4
Serilog Sink for OpenObserve

This Serilog Sink allows to log to OpenObserve.
What is this sink ?
This project is a sink for the OpenObserver.
Quick start
Install sink in your project.
dotnet add package Serilog.Sinks.OpenObserve-KKP
Register the sink in code.
var logger = new LoggerConfiguration()
.WriteTo
.OpenObserve(
"url",
"organization"
"login",
"key"
).CreateLogger();
You can optionally add parameter streamName to write logs to specified stream (default value is default)
Use serilog log method to log details (please check sample project).
_logger.Debug("Debug message");
Using appsettings.json configuration
First install Serilog.Settings.Configuration package if you don't already have it:
dotnet add package Serilog.Settings.Configuration
In your appsettings.json file, under the Serilog node, add following entries:
{
"Serilog": {
"Using": ["Serilog.Sinks.OpenObserve-KKP"],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "OpenObserve",
"Args": {
"url": "https://api.openobserve.ai",
"organization": "[organization]",
"login": "[login]",
"key": "[key]"
}
}
],
"Properties": {
"Application": "OpenObserve.Tests"
}
}
}
With provided configuration following code should be send:
{"@t":"2023-08-03T20:53:20.2872427Z","@m":"Debug message","@mt":"Debug message","@i":"9515f1e2","@l":"Debug","SourceContext":"OpenObsere.Sample.CustomBackgroundService","Application":"OpenObserve.Tests"}
On server side it should looks like:
{
"_i": "9515f1e2",
"_l": "Debug",
"_m": "Debug message",
"_mt": "Debug message",
"_t": "2023-08-03T20:53:20.2872427Z",
"_timestamp": 1691096013274896,
"application": "OpenObserve.Tests",
"sourcecontext": "OpenObsere.Sample.CustomBackgroundService"
}
Please note:
- field
_timestampis added on server side - field
_mtcontains message template, e.gCounter: {CounterValue} - field
_mcontains rendered message, e.g.Counter: 2 - field
_iis calculated on message template text, it's different for each different message template
More information about using Serilog is available in the Serilog Documentation.
No packages depend on Serilog.Sinks.OpenObserve-KKP.
.NET Standard 2.0
- Serilog (>= 4.0.0)
- Serilog.Expressions (>= 5.0.0)
- Serilog.Sinks.PeriodicBatching (>= 5.0.0)
- System.Text.Json (>= 8.0.3)