Rendering/Formatting a Message Serialized via JsonFormatter without renderMessage = true

847 views
Skip to first unread message

Ryan Farmer

unread,
Oct 3, 2016, 1:19:25 PM10/3/16
to Serilog
I'm using Serilog to generate structured logs that I store on a central storage for processing later.  I use JsonFormatter with renderMessage = true so I can read the logs when needed.

I'd like to be able to render the log the way Serilog does with MessageTemplateTextFormatter from the JSON formatted logs without using renderMessage = true so I can save some storage space.  

Is there a way to parse data from the JSON-formatted entry and create a Serilog.Events.LogEvent that I can pass to MessageTemplateTextFormatter?  Parsing the properties and exceptions and trying to re-create those objects is not possible currently.  Or is there an external library that will take that data and generate a human-readable/formatted string?  I know seq does this, but don't always want to load it into seq first if I am programmatically parsing and sending me a list of human-readable errors.

nblum...@nblumhardt.com

unread,
Oct 3, 2016, 5:26:19 PM10/3/16
to Serilog
Hi Ryan,

There's nothing published, but I just whipped up this Gist the demonstrates doing it with MessageTemplates and JSON.NET:


It'd be great to hear how you go with it, let me know if you hit any issues.

Cheers,
Nick
Reply all
Reply to author
Forward
0 new messages