Output templates

278 views
Skip to first unread message

Nicolas Tenoutasse

unread,
May 30, 2016, 6:35:28 AM5/30/16
to Serilog
Hello,

First, I have to say that I'm just discovering Serilog & Seq and that I'm pretty impressed!


Anyway, trying to use them in a MVC project, I have a few questions which I'm surprised that no one else seems to have addressed while they seem basic needs to me... But then maybe I missed something :-p

In the doc you say:
Each sink is provided with an output template that controls how the sink renders events. This template uses the same format as the message templates that go with log events themselves, and can be specified during configuration.
But to me it seems that the seq sink doesn't have such a property, in fact only console has it, no?

Now back to what I am trying to achieve, for example, I want to enrich my logs kind of globaly 

Log.Logger = new LoggerConfiguration()
                  .Enrich.WithProperty("App", APP_NAME)
                  .WriteTo.Seq("http://localhost:5341")
                  .CreateLogger();

everything works except I cannot have this mentionned in the message itself, if you see what I mean. I would like to do something like

Log.Information("{App}: {Action} {id}", "view", id);

But of course that won't work since {App}  will take the first parameter....

something similar to output templates would do it (not 100% but still)

Nicolas

nblum...@nblumhardt.com

unread,
May 30, 2016, 6:51:31 AM5/30/16
to Serilog
Hi Nicolas!

In Seq, you can click the green tick-mark beside a property name and select "Show as tag" to achieve the same effect.

Hope this helps,
Nick

Nicolas Tenoutasse

unread,
May 30, 2016, 9:21:17 AM5/30/16
to Serilog
Indeed, it does the trick but requires a (small) manual intervention.

But it's not really the answer to the question ;-)  which was about suport for output templates in seq...

Nicolas

nblum...@nblumhardt.com

unread,
May 30, 2016, 6:13:41 PM5/30/16
to Serilog
Ah but it does! :-) ... Output templates are all about rendering a structured event into a plain-text medium. If you have a store that fully supports structured data, like Seq/Splunk/Elasticsearch etc, there are more interesting ways to achieve the same kinds of goals.

Nicolas Tenoutasse

unread,
Jun 2, 2016, 9:51:27 AM6/2/16
to Serilog
but in output templates, you can define placements and "decorations" if you see what I mean

Nicolas
Reply all
Reply to author
Forward
0 new messages