I've been trying to sort out my logging situation (How to properly manage logback configrations in development and production using SBT & Scala?), and I've run across a funny problem.
According to the logback documentation, logback checks for logback-test.xml
before it checks for logback.xml
.
I have the following files:
src/main/resources/logback.xml
src/test/resources/logback-test.xml
So I figured that when running sbt test
, it would look to the logback-test.xml
. This is true in intellij (which manages test execution itself), but does not seem to be true when running from the command line.
I renamed my logback.xml and turned on logback debugging, and here is the output. Clearly it's looking for the files in the 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'm speculating that it's because the test resources are in the test-classes directory, but I have no idea how to properly fix this.
SECONDLY, supplying -Dlogback.configurationFile=config/logback-#{environment}.xml
doesn't seem to do anything, it toally ignores it.
Any thoughts?