How to change log level in tests


I need to change the log level to TRACE for some of my integration tests.

By looking at TestContainer code, I found out that I can use a “test-logback.xml” file which is great, but where should I put it : under tomcat/conf ? in the classpath ?

BTW, this topic could be documented in the Testing and/or Logging section of the documentation.


Hi Mike,
You should create your own logback config file and place and specify it in the logback.configurationFile system property.
You can copy test-logback.xml from the platform to the root of the test folder of your project’s core module as my-test-logback.xml and change it as you want. Then add a static initializer to your test container:

public class MyTestContainer extends TestContainer {

    static {
        System.setProperty("logback.configurationFile", "my-test-logback.xml");
    // ...

We’ll add it to the docs, thanks for reminding.

Thanks Konstantin