Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropwizard Custom log file via Logback

Looking at the source code for dropwizard I can see that there is custom glue code to read the .yml file and set up logging.

I want my own custom log file, but I'd like to use the rotation and compression that already exists in dropwizard.

Is there a way, short of cloning the code to do this?

https://github.com/dropwizard/dropwizard/tree/master/dropwizard-logging/src/main/java/io/dropwizard/logging

Specifically it looks like need to create my own class which inherits from io.dropwizard.FileAppenderFactory

Or am I attacking this problem from the wrong angle?

like image 637
user1509463 Avatar asked Oct 21 '22 15:10

user1509463


1 Answers

There is a way but you need to change the dropwizard source and recompile it again if you are using the lib.In the Application class of dropwizard that you are extending there is static block like blow,just comment the lines and use your own logback.xml file.It really is a pain in the ....

static {
    // make sure spinning up Hibernate Validator doesn't yell at us
    LoggingFactory.bootstrap();
}
like image 84
armin Avatar answered Oct 23 '22 11:10

armin