Skip to content

mlangc/zio-interop-log4j2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZIO Interop Log4J2

Latest Release Latest Snapshot

This library provides ZIO fiber aware MDC logging for Log4j 2.

Usage

  1. Add libraryDependencies += "com.github.mlangc" %% "zio-interop-log4j2" % version to your build.sbt
  2. Add -Dlog4j2.threadContextMap=com.github.mlangc.zio.interop.log4j2.FiberAwareThreadContextMap to your JVM startup parameters. If you can't, try to set the log4j2.threadContextMap system property programmatically as early as you can. The property must be set before Log4j2 is initialized.
  3. Integrate com.github.mlangc.zio.interop.log4j2.FiberAwareThreadContextMap.assertInitialized into your initialization code. Fiber aware MDC logging will not work properly without this call.
  4. Use org.slf4j.MDC as you would normally and observe that it now respects fiber boundaries.
  5. If you start getting annoyed by wrapping interactions with MDC in ZIO effects, take a look at slf4zio which ships an MDC convenience wrapper for ZIO called MDZIO.

About

ZIO Fiber aware MDC logging for LOG4J2

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published