I have a scala project where i am using scala-slf4j logging and logback. When the project is executed via command line as below
java -jar <sample_project.jar> -Dlogback.configurationFile=/tmp/logback.xml
It uses logger class as 'ch.qos.logback.classic.Logger' but is not taking the logback.xml configuration.
Same works fine if i put the logback configuration xml under /src/main/resources.
import org.slf4j.LoggerFactory
object SampleProj {
val logger = LoggerFactory.getLogger(this.getClass)
logger.info("SCALA Logging")
}
build.sbt
"ch.qos.logback" % "logback-classic" % "1.1.2",
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
Another approach which is tried is extracted the scala project jar and executed the main class as below
java com.test.SampleProj -Dlogback.configurationFile=/tmp/logback.xml
Some other methods i tried was,
- Set the classpath and put the logback xml
- passing as "-Dlogger.file=/tmp/logger.xml"
- passing as -Dlogger.resource=/tmp/logger.xml
Can someone help me in resolving this. Thanks