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

Get the diagnostic context in the event. #5

Open
tdeverdiere opened this issue Apr 20, 2023 · 3 comments
Open

Get the diagnostic context in the event. #5

tdeverdiere opened this issue Apr 20, 2023 · 3 comments

Comments

@tdeverdiere
Copy link

tdeverdiere commented Apr 20, 2023

That would be cool to have the map of diagnostic context in the final log event. This is equivalent to ThreadContext Map in log4j2, and to MDC in logback.

That would allow to test that ThreadContext.put() and MDC.put is being called.

@netmikey
Copy link
Owner

LogUnit uses Slf4j's LoggingEvent interface to capture logging events because we'd rather not invent yet another LoggingEvent interface. Slf4j's interface doesn't provide a way to access the MDC unfortunately. As far as I can see, the new Slf4j v2 LoggingEvent doesn't provide it either.

The underlying Log4j2 and Logback events both provide access to their MDC implementation though. You might want to check with the Slf4j project to see if they'd be willing to add a getMDC() method of some sort to their LoggingEvent interface.

@tdeverdiere
Copy link
Author

tdeverdiere commented Apr 21, 2023

Yes you are right. Or maybe we could have a wrapper in logunit ?

I created an issue on Slf4j : qos-ch/slf4j#345

@netmikey
Copy link
Owner

We could also inherit / extend slf4j's LoggingEvent interface but let's wait for the slf4j project's opinion first.

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

No branches or pull requests

2 participants