Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Fix log events not being written to Sink when exception has no stacktrace #285

Merged

Conversation

marcin-brzozowski
Copy link
Contributor

What issue does this PR address?
#281 - Log Events not Written to Sink with Inner Exceptions.

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

  • The commit follows our guidelines
  • Unit Tests for the changes have been added (for bug fixes / features)

Other information:
A null reference exception was thrown when trying to format Exception with no stacktrace (either root or inner one). This caused log events not to be written to the Sink.

This only happens, when someone tries to log an exception that wasn't thrown, but created via the new keyword. The latter one has most properties set to null because it was not thrown. While it's rare that such instance of the Exception class is used, the formatter should still be able to handle it gently.

I think that when formatStackTraceAsArray is enabled, the StackTrace and RemoteStackTrace Exception properties, when null, should be formatted as empty arrays.

…race

A null reference exception was thrown when trying to format Exception with no stacktrace (either root or inner one). This caused log events to not be written to Sink.
@mivano mivano merged commit 5fe45bd into serilog-contrib:dev Oct 19, 2019
@mivano
Copy link
Contributor

mivano commented Oct 19, 2019

Thanks for the PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants