serilog-sinks-opentelemetry icon indicating copy to clipboard operation
serilog-sinks-opentelemetry copied to clipboard

Custom `ITextFormatter BodyFormatter` for log message bodies

Open DevProJSSV opened this issue 10 months ago • 12 comments

Hello team,

I am trying to find a way to format otlp logs when using the opentelemetry sink :

Log.Logger = new LoggerConfiguration()
    .WriteTo.OpenTelemetry(options =>
    {
        options.Endpoint = "http://127.0.0.1:4317";
        options.ResourceAttributes = new Dictionary<string, object>
        {
            ["service.name"] = "test-logging-service",
            ["index"] = 10,
            ["flag"] = true,
            ["value"] = 3.14
        };
        options.Format=json;   -------- > # Something like this
    })
    .CreateLogger();

I know there is a way to do it with.WriteTo.Console() bust as I am leveraging otlp communication I would like to send all structured in Json using WriteTo.OpenTelemetry().

May you recommend me any approach?. Thank you in advance @nblumhardt

DevProJSSV avatar Apr 05 '24 15:04 DevProJSSV