Reputation: 515
I would like to load different logback configurations based on SCALA_ENV environmental variable.
From Play2.5 docuemntation i found this example but it is not clear.
Also MyComponenets is unresolved and compilation fails.
Upvotes: 1
Views: 316
Reputation: 515
Not an ideal solution but I'm changed the -Dlogger.resource file based on environment in build.sbt
lazy val logBackXml = sys.env("env").toLowerCase() match {
case "prod" => "-Dlogger.resource=logback.xml"
case "test" => "-Dlogger.resource=logback.test.xml"
case "qa" => "-Dlogger.resource=logback.qa.xml"
case _ => "-Dlogger.resource=logback.dev.xml"
}
javaOptions in Production += logBackXml
Upvotes: 0
Reputation: 18157
This is how I do it in my build.sbt
file:
// logback for Prod
javaOptions in Production += "-Dlogger.resource=logback.prod.xml"
// logback for testing
javaOptions in Test += "-Dlogger.resource=logback.test.xml"
My default one is the dev, which is just left at the default location.
Upvotes: 1