Skip to content

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.

Write(level, eventId, state, exception, formatter, out parsed);
}
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