saleem-mirza / serilog-sinks-mysql

Serilog sink that writes to MySQL database.
Apache License 2.0
35 stars 25 forks source link

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

Open zd-dalibor opened 4 years ago

zd-dalibor commented 4 years ago

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);
a7son commented 3 years ago

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.

zd-dalibor commented 3 years ago

@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