Skip to content
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

Do not swallow exception from Audit #218

Merged
merged 2 commits into from
Mar 12, 2023
Merged

Conversation

sungam3r
Copy link
Contributor

fixes #209

I spent a few hours today to figure out why my sink from audit config not throwing an exception. Without this fix audit sink as a feature is useless when working through MEL.

}
catch (Exception ex)
catch (Exception ex) when (!parsed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the code clearer, could Write become PrepareWrite, with out ILogger logger, out LogEvent evt?

PrepareWrite() would then be called in the try/catch block, and logger.Write(evt) outside it, yielding the same behavior but avoiding the need for the parsed Boolean (which is a bit tricky to follow).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks great 👍

@nblumhardt nblumhardt merged commit 484987f into serilog:dev Mar 12, 2023
@sungam3r sungam3r deleted the exception branch March 13, 2023 06:10
@nblumhardt nblumhardt mentioned this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No exceptions emitted when generated by faulty audit log configuration
3 participants