Slick logging with slf4j-simple

2019-04-12 15:14发布

问题:

I am using slf4j-simple in my project. I would like to change logging level for slick to INFO. After reading Logging options for Slick and Class SimpleLogger docsI have tried to add following options to my VM line:

-Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
-Dlogger.scala.slick=INFO
-Dlogger.scala.slick.jdbc.JdbcBackend.statement=INFO
-Dorg.slf4j.simpleLogger.log.scala.slick=INFO

I see a few INFO level logs comming from jetty, therefore the basic logging seems to be working. I am also able to change level of logs shown by using -Dorg.slf4j.simpleLogger.defaultLogLevel=TRACE, but even that only shows more jetty logs, no Slick logs are shown to me.

How can I configure slf4j-simple to shown slick logs to me?

回答1:

According to http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html the correct system property should be

-Dorg.slf4j.simpleLogger.log.scala.slick=debug

instead of

-Dlogger.scala.slick=INFO 

For reference, the list of all loggers used by Slick can be found in logback.xml. We only use the debug level with all of them.