-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a way to format Exceptions #26
Comments
Hi @oscarmorasu , thanks for the note. SerilogExceptions is an add-on to Serilog that explores some of this space, and might be handy for you. Unfortunately, in .NET, I think right now we can accept this as a data point, but can't move it forward in the short term. Thanks! |
I'd like to add a +1 data point here too. For example, I think it would be a great local development experience if the console sink was able to easily highlight exceptions, and I'd prefer not to have to re-parse them from the |
@oscarmorasu I solved this problem with my own enrichers (essentially the same as Serilog.Exceptions). |
Hey all! I think https://github.com/serilog/serilog-expressions now provides a reasonable place to consider hooking in this kind of functionality. I don't think it's something we'd tackle in Serilog.Expressions. Since it's a broad and tricky thing to get right I think it's best to close this and just consider specific proposals. Cheers! |
In your current implementation exceptions are formatted as "ex.ToString()".
It would be great to format the Exception as JSON, spitting out the Message, Type, Method and StackTrace as JSON properties. The StackTrace could be formatted as a JSON array, where each line is one string in the array. You can see that concept in action in this PR.
This is extremelly helpful when aggregating exceptions by Type or Message in tools like Splunk.
I ended implementing this in my own ITextFormatter, but I think this should be part of the library.
If/when you decide to iterate on the JSON formatter, I would be more than happy to contribute with my solution.
Since Exceptions are a very important element of error logging, have you considered introducing an
IExceptionFormatter
, with a methodFormatException
, and sink authors could implement their own formatting (in this case JSON).The text was updated successfully, but these errors were encountered: