I tried to figure out my logging situation ( How to properly manage log configurations in development and production using SBT and Scala? ), And I "are you facing a funny problem.
According to the logbook documentation , a log check checks for logback-test.xml before it checks logback.xml .
I have the following files:
src/main/resources/logback.xmlsrc/test/resources/logback-test.xml
So, I realized that when running sbt test it will look at logback-test.xml . This is true in intellij (which controls the execution of the test itself), but when run from the command line, this does not seem true.
I renamed my logback.xml and turned on log debugging, and here is the output. Obviously, it searches for files in reverse order:
14:58:21,203 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [/home/rathboma/Projects/personal/beekeeper/src/main/resources/logback.xml] 14:58:21,206 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 14:58:21,206 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/home/rathboma/Projects/personal/beekeeper/target/scala-2.10/test-classes/logback-test.xml]
I suppose this is because the test resources are in the test class directory, but I have no idea how to fix this correctly.
SECOND, supplying -Dlogback.configurationFile=config/logback-#{environment}.xml does not seem to do anything, it generally ignores it.
Any thoughts?
scala logging slf4j sbt logback
Matthew Rathbone
source share