Scalalogging will not work in sbt playproject with logging in stdout

My sbt is set up based on this wonderful answer: Confused how to set up a project for several sbt projects

So, in Dependencies.scala added:

 val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging-slf4j" % scalaLoggingVersion //val logbackCore = "ch.qos.logback" % "logback-core" % logbackVersion val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion 

(Commented on logbackCore - do I need this?)

Added scalaLogging and logbackClassic to commonDependencies (other libs removed):

 val commonDependencies: Seq[ModuleID] = Seq( scalaLogging, //slf4j, //logbackCore, logbackClassic ) 

Also in the /services sbt module this is added to the UserServiceImpl class:

 import com.typesafe.scalalogging.slf4j.LazyLogging class UserServiceImpl (.....) extends SecurityService with LazyLogging { def show(.....) { logger.trace("UserService.show called") logger.debug("UserService.show called") } } 

In addition, logback.xml added to / services / resources:

 <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%logger:%line - %msg%n</pattern> </encoder> </appender> <root level="debug"> <appender-ref ref="STDOUT" /> </root> </configuration> 

Now, when my playback application starts, the log is not displayed when sbt run , normal playback logs are great for my controllers, etc.

For good measure, also dumped a logback.xml in the /conf folder, but still no output.

I'm not sure what I'm doing wrong here, hoping that someone can clarify everything for me.

Note. I use sbt to compile my project, but I am making changes to IntelliJ, and for some reason IntelliJ is not writing scala -logging correctly. My import is highlighted in red, the LazyLogging keyword that I use in my UserService with LazyLogging is in red. Also my actual log entries, such as logger.debug, the word "logger" is red. This does not seem to fix them, but sbt will compile it.

+6
source share
1 answer

To do work with the log, you must edit application.conf and comment out all the logger settings: logger.root , logger.play , logger.application , etc.

Then put the log configuration in a file called application-logger.xml (name is important) in your /conf directory.

+1
source

Source: https://habr.com/ru/post/969844/


All Articles