Logmatic.io Blog

Serilog and Logmatic.io
“Json logging as a charm”

serilog

And we’re back!

This week we released a new Logmatic.io connector for the ever growing in popularity logging library Serilog.

Serilog is one of the sweetest logging libraries I have ever seen, even if my background is in Java.
So we developed, tested and released a sink that allows you to stream your events and logs straight to Logmatic.io in Json.

If you want to try it, simply install the sink Serilog.Sinks.Logmatic via NuGet as usual, plus the new Serilog connector directly to your code.

/ Instantiate the logger
var log = new LoggerConfiguration()
    .WriteTo.Logmatic("<YOUR_API_KEY")
    //.WriteTo.Whatever ...
    .CreateLogger();

// An example
var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;
log.Information("Processed {@Position} in {Elapsed:000} ms.", position, elapsedMs); 

And the output looks like as:

{
    "MessageTemplate":"Processed {@Position} in {Elapsed:000} ms.",
    "Level":"Information",
    "Timestamp":"2016-09-02T15:02:29.648Z",
    "Renderings":{
        "Elapsed":[
            {
                "Format":"000",
                "Rendering":"034"
            }
        ]
    },
    "Properties":{
        "Position":{
            "Latitude":25,
            "Longitude":134
        },
        "Elapsed":34
    }
}

And this is it: nothing else to do, just enjoy your metrics, logs and events.

I’ll leave you some links to dig deeper:

@gpolaert

Have fun and keep on logging smiley

Related Posts