-
Notifications
You must be signed in to change notification settings - Fork 404
Open
Description
Describe the bug
I cannot output MDC content in logs if the log backend is log4j2.
To Reproduce
object MyAppMain extends MyApp
class MyApp extends HttpServer with Logging {
override protected def configureHttp(router: HttpRouter): Unit =
router
.filter[LoggingMDCFilter[Request, Response]]
.filter[TraceIdMDCFilter[Request, Response]]
.filter[FinagleRequestScopeFilter[Request, Response]]
.add[AController]
}
class AController @Inject() extends Controller {
get("/go") { _: Request => {
logger.info("hello world")
response.ok.contentType(MediaType.PlainText).body("hello world")
}
}
}With log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %X - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<!-- Info by default -->
<Root level="info" additivity="false">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>Expected behavior
hello world Console log lines with the content of the MDC.
Additional context
It works if I use Logback.
If I remove LoggingMDCFilter from the filters chain, it works with log4j2, of course, but I'm not sure this is a very good idea.
Metadata
Metadata
Assignees
Labels
No labels