Why does logback use both logback-test.xml and logback.xml as configuration file name?

Asked

Viewed 53 times

2

Reading the logback manual on configuration section, he says he looks for the following configuration files, in order:

  1. logback-test.xml
  2. logback.groovy
  3. logback.xml

Why there is a suffix -test? For me, logback.xml makes sense. Why link the name of the file?

1 answer

3


Drive tests typically include the entire project in the classpath, including configuration files, among them the logback.xml.

It turns out that the unit test log settings are usually different from the project’s log configuration for production. A simple way to resolve this is to put the file logback-test.xml in the unit test classpath. This way, Logback will know when to choose the correct configuration file and the name will make it clear if you are using the production file (logback.xml) or the test (logback-test.xml).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.