serilog-sinks-testcorrelator
serilog-sinks-testcorrelator copied to clipboard
Seems like multiple calls to CreateContext in the same thread just accumulates ContextGuids to the AsyncLocal
And while GetLogEventsFromContextGuid() seems to reduce the number of LogEvent's in the result set (because a Dispose removes the ContextGuid from ContextGuids collection, GetLogEventsFromCurrentContext() doesn't look at the ContextGuids collection and seems to grab all the logs from the AsyncLocal collection.
This is problematic when running XUnit tests. All logs from all tests in the file end up in the same AsyncLocal collection. So the number of LogEvent's just grows as the test runner executes unit tests. It would be cool if there were a way to purge all the logs in AsyncLocal
I'm going to debug this locally to see what's going on. Will post back later.
I'm going to close this since it's been three years and I don't think there's a bug here. It's intentional that this library accumulates LogEvents since there is no way for us to know when the last time a LogEvent will be requested is. I think adding a purge method would cause more trouble than benefit, especially for parallel or async tests.