serilog-sinks-mysql icon indicating copy to clipboard operation
serilog-sinks-mysql copied to clipboard

Message is written in raw format in log table (with placeholders)

Open zd-dalibor opened this issue 4 years ago • 2 comments

I notice that message is written in raw format in log table. For example:

Hosting environment: {envName}

and in properties column is json with values

{"envName":"Development","SourceContext":"Microsoft.Hosting.Lifetime","ApplicationName":"***"}

I need to show content of this table as html table so I need some way to show complete message with place holders replaced. Is there some easy way for doing this.

Full message can be generated with something like this in sink implementation:

// _formatProvider is instance of IFormatProvider
var message = logEvent.RenderMessage(_formatProvider);

but in this implementation StringWriter is used

var logMessageString = new StringWriter(new StringBuilder());
logEvent.RenderMessage(logMessageString);

zd-dalibor avatar Apr 11 '20 23:04 zd-dalibor

Do use the nugget package? I think you should update your nugget package to 4.5.0-dev-00044 for me it work well, because the raw format will be inserted to Template column and Message placeholder will be replaced by the real value because i have the same problem.

a7son avatar Nov 18 '20 07:11 a7son

@a7son Thanks for this information. I currently do not have time to test this but if this is working for you please feel free to close this issue

zd-dalibor avatar Nov 18 '20 08:11 zd-dalibor