[logback-user] Auto configuration within unit tests
simon.brandhof at hortis.ch
Thu Oct 19 21:40:39 CEST 2006
Auto-configuration is very useful. No more explicit initialization.
The configuration file is automatically loaded from the classpath
thanks to naming convention (for example "log4j.xml" or future
"logback.xml"). Logback does not manage yet this feature, but I think
it is currently in development.
I wish Logback resolves a common need I have with log4j :
autoconfiguration within unit tests. The idea is to have a
configuration file specific to unit tests (for example with DEBUG
levels) without intrusive initialization parameters (Java code, system
property, ...). The are only two solutions with log4j :
1/ manage files ordering into the classpath. The unit test log4j.xml
precedes the "official" log4j.xml.
2/ have only the unit test log4j.xml into the classpath
Those solutions are not so simple to set with tools like maven or
eclipse. For example Maven 2 sets the test classpath with the
directories src/main/resources then src/test/resources. And no way
for me to change the default behaviour !
Here is a draft of solution. Logback loads a file named
logback-test.xml instead of logback.xml if the classpath contains a
class from the package junit.framework or org.testng.
Is it possible ? Do you have any suggestions ?
More information about the Logback-user