
Hi Simon, Your question is close to Michael Newcomb's post of a few weeks ago. One of the last key features missing in logback is support for default configuration. Anyway, this is relatively easy to do and will be added shortly. It should be part of logback version 0.5 (to be released in the next 48 hours), if not, version 0.6. Coming back to your question, assume we want to keep it simple. What if during auto-configuration logback gave higher priority to the file logback-test.xml, and only it could not be found, search for logback.xml, this independently of junit or testng classes? What would be wrong with that approach? It seems to me that this approach would work both with Eclipse and Maven. Only when the file "logback-test.xml" found its way into production, we would run into trouble. Is that likely? We could further facilitate the life of the developer by proposing a very simple default configuration in the absence of both logback-test.xml and logback.xml files. WDYT? At 09:40 PM 10/19/2006, Simon BRANDHOF wrote:
Hello,
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 ? Simon
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch