[logback-user] Additional logback config

Christian Lipp Christian.Lipp at xion.at
Thu Jul 5 07:54:18 CEST 2012


What I didn't know (because it is not mentioned under http://logback.qos.ch/manual/configuration.html#auto_configuration) is that logback allows the external configuration of a config file via "-Dlogback.configurationFile=<path>". I assume the correct order is:

0. use config file if given via -Dlogback.configurationFile=<path>
1. Logback tries to find a file called logback.groovy in the classpath.
2. If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
3. If no such file is found, it checks for the file logback.xml in the classpath..
4. If neither file is found, logback configures itself automatically using the BasicConfigurator which will cause logging output to be directed to the console.

So I was able to solve my problems. I still would like to have answers to the following questions:
- Is it possible to determine if the logging infrastructure is set up or not?
- Is it possible to tell logback to do a autoconfig (1-4) or to load a logback.xml from the classpath?

Kind regards, CL

 -----original message-----
Betreff: [logback-user] Additional logback config

Hello!

I have a web application running under Tomcat with uses Logging separation as described here:
http://logback.qos.ch/manual/loggingSeparation.html#ContextJNDISelector

This means that logback jars are located under  ${catalina.home}\lib.

For the build I use maven and perform also a integration test with the maven-failsafe-plugin and the tomcat-maven-plugin. The tomcat-maven-plugin has the logback jars as dependencies, but I do not know how to provide a logback.xml. Of course I could use a ServletContextListener to distinguish programmatically between development and production environment.

What are best practices to separate development logging, integration test logging and production logging when development logging should use the config inside the war and production logging should use the logging set up by the operational team in the Tomcat?

Is it possible to determine if the logging infrastructure is set up or not? I could use this information in a ServletContextListener to force a new initialisation.

Is it possible to tell logback to use the config file in WEB-INF\classes even if the logback jars are located under  ${catalina.home}\lib?

Kind regards, CL
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list