datalust / serilog-sinks-seq

A Serilog sink that writes events to the Seq structured log server
https://datalust.co/seq
Apache License 2.0
239 stars 50 forks source link

How to use ITextFormatter? #139

Closed balkarov closed 4 years ago

balkarov commented 4 years ago

Hello.

I want to modify text before log. Seq supports ITextFormatter for it. How to use it in seq?

nblumhardt commented 4 years ago

Hi Ruslan,

This would need to be done in the Serilog pipeline before the event reaches the Seq sink.

ITextFormatter works for text-based sinks, but sinks for structured data like the Seq one will use the LogEvent.MessageTemplate property as-is.

Check out the example in https://github.com/nblumhardt/serilog-sinks-timewarp/blob/master/Serilog.Sinks.TimeWarp/Program.cs to see how a wrapper sink can be constructed that might re-write the message template, if this is needed.

Hope this helps, Nick