Dropwizard & Log4j2 configuration

2,278 views
Skip to first unread message

Liliana Santos

unread,
Sep 26, 2015, 7:32:25 PM9/26/15
to dropwizard-dev, liliana...@hotmail.com
Can someone please help me with instructions on how to configure my Java application (using Dropwizard) to log via Log4j2 ? 

I have custom Log4j2 apppenders already coded that I need to use and Dropwizard seems to use logback by default, I cannot seem to find the exact information of how to override this.  

(1) I have updated my pom.xml with (slf4j-apilog4j-slf4j-impl, log4j-core, log4j-api)

(2) I run my application with : java -jar -Dlog4j.configurationFile=log4j2.xml app-1.0-SNAPSHOT.jar  server configuration.yaml

and I get the exception :
Exception in thread "main" java.lang.IllegalStateException: Unable to acquire the logger context
at io.dropwizard.logging.LoggingUtil.getLoggerContext(LoggingUtil.java:46)
at io.dropwizard.logging.BootstrapLogging.bootstrap(BootstrapLogging.java:45)
at io.dropwizard.logging.BootstrapLogging.bootstrap(BootstrapLogging.java:34)
at io.dropwizard.Application.<init>(Application.java:24) 
....

Thanks in advanced!

Jochen Schalanda

unread,
Sep 27, 2015, 9:00:26 AM9/27/15
to dropwiz...@googlegroups.com
Hi Liliana,

Dropwizard is using Logback (http://logback.qos.ch/) as its logging framework of choice. It is non-trivial (and probably not worth the effort) to replace that with another logging framework like log4j 2.


Cheers,
Jochen
Reply all
Reply to author
Forward
0 new messages