serilog-contrib / Serilog.Logfmt

Simple Serilog formatter to output Logfmt
Apache License 2.0
9 stars 5 forks source link

Stack trace #10

Open arins opened 1 month ago

arins commented 1 month ago

Shouldn't the stacktrace be outputed within a key?

stacktrace=some stacktrace

https://github.com/serilog-contrib/Serilog.Logfmt/blob/e157ce692de97a903d0c4a3820aac9c1d4bbde5e/Serilog.Logfmt/LogfmtFormatter.cs#L96

currently it is just printed out is that really valid logfmt? Grafana cloud skips it what I can see.

wavedeck commented 2 weeks ago

As of my comment, the logfmt serialization format does not have an official specification or RFC available to describe how the format has to be structured. So printing out stack traces without a key, regardless if on a single or multiple lines technically does not go against the logfmt structure.

I do not believe that Heroku (who is said to have brought this format to public attention) is coming up with an official specification any time soon, so this decision of format will be a community effort until logfmt gets more popular.

I also agree that stack traces should get their own key assigned, which in turn reduces complexity and improves compatibility with many log parsers. So in my opinion, adding keyed single line stack traces should be a configuration option in Serilog.Logfmt.

Something like adding .LogStackTrace(LogfmtStackTraceFormat.Keyed) could improve this library further while keeping backwards compatibility with already existing implementations and applications.

Should this be a considered PR?