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

Pass key-value properties into events in slf4j-reload4j. #394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josephw
Copy link
Contributor

@josephw josephw commented Feb 5, 2024

I'm aiming to migrate an existing codebase off Log4j as a logging framework. Logging is through SLF4J, but there's also extensive direct use of Log4j's org.apache.log4j.MDC to pass values (other than Strings) through to a Layout that produces structured logging output.

An incremental migration would be significantly easier if I were able to adopt SLF4J's new fluent API without having to simultaneously change the backend logging framework.

This PR makes exactly that change: the key-value properties from the fluent API are merged into the snapshot of the MDC, leaving the existing logging backend with exactly the same data, while the logging calls lose their direct dependency on Log4j.

It's not clear to me whether this approach was considered and rejected, because it conflates the two different types of property, or whether it's suitable as a general purpose change.

Merge MDC and fluent key-value properties together in slf4j-reload4j, so
the fluent API can be used with an appropriate Layout.

Signed-off-by: Joseph Walton <jwalton@atlassian.com>
@josephw josephw force-pushed the merge-key-values-into-reload4j-event-properties branch from 2ac1439 to b1c8d63 Compare May 10, 2024 11:07
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.

None yet

1 participant