Alternate SLF4J Binding or Config For Unit Test?

后端 未结 1 618
星月不相逢
星月不相逢 2021-01-11 16:29

I\'d like to be able to switch the bindings for SLF4J for unit testing over to the simple version, but it seems there is no easy way to config this. Basically, my built proj

相关标签:
1条回答
  • 2021-01-11 16:52

    A better approach is to facilitate your logging framework. Logback library for instance first searches for logback-test.xml and if it is not available, it looks for logback.xml. If you place logback-test.xml in /src/test/resources, it will be picked up for unit tests. In this file you configure console logging instead of file.

    If you are still using Log4J, simply place log4j.xml in /src/test/resources - this folder is available on classpath before /src/main/resources, so Log4J will use it instead of ordinary /src/main/resources version, while still loading the latter version for final builds (/src/test/resources isn't even available then).

    0 讨论(0)
提交回复
热议问题