-
Notifications
You must be signed in to change notification settings - Fork 82
Add SLF4J MDC support for JUL #79
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor detail, otherwise looks good to me, thanks 🎉
if (copyOfContextMap != null ) { | ||
return copyOfContextMap; | ||
} | ||
return new HashMap<String, String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Collections.emptyMap()
|
||
@Override | ||
public Map<String, String> getMDC() { | ||
return new HashMap<String, String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Collections.emptyMap()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I somehow assumed that this was not possible as I first had return Objects.requireNonNullElse(copyOfContextMap, Collections.emptyMap());
but maven wouldn't compile that.
On a side note, is it intended that maven compiles to java 6 (legacy support or something else)? My idea hints me towards code style improvements that don't compile. e.g. multi catch blocks like this: catch (Exception | LinkageError e) { return Unavailable.INSTANCE; }
jul-ecs-formatter/src/main/java/co/elastic/logging/jul/MdcSupplier.java
Outdated
Show resolved
Hide resolved
…ng MDC in some JVM implementations.
Pull request for issue: #78.
This pull requests adds mdc support for JUL which is useful for legacy applications that want to use APM.
Before merging please review the MdcSupplier interface. I implemented it similar to the
ObjectMessageJacksonSerializer
interface but I noticed that theObjectMessageJacksonSerializer
does not have unit tests for when there is no Jackson Objectmapper on the classpath. Currently this is similar to my implementation ofMdcSupplier
where theMdcSupplier.Unavailable
, which is used if slf4j is not on the classpath, is not tested with unit tests. I am not really sure how to proceed with this issue.