serilog-contrib / Serilog.Sinks.Logz.Io

Apache License 2.0
15 stars 11 forks source link

Boost properties to event #5

Closed sandermvanvliet closed 5 years ago

sandermvanvliet commented 5 years ago

This PR adds a configuration option to boost properties in the message template (or log context) a level up to the event.

Normally the sink works like this:

Log.Information("Hello, {name}!", "world");

resulting event json:

{
    "message": "Hello, world!",
    "level": "warning",
    "properties.name": "world"
}

There may be cases where the properties prefix isn't desired. In that case you can configure the sink as follows:

new LoggerConfiguration()
    .WriteTo.Sink(
        new LogzioSink(
            new HttpClient(),
            "testAuthCode", 
            "testType", 
            100,
            TimeSpan.FromSeconds(1), 
            boostProperties: true))

the resulting json then becomes:

{
    "message": "Hello, world!",
    "level": "warning",
    "name": "world"
}
mantasaudickas commented 5 years ago

Package uploaded with version 2.1.0

sandermvanvliet commented 5 years ago

Cool, thanks!