How do I configure Spring and SLF4J so that I can get logging?

后端 未结 7 953
借酒劲吻你
借酒劲吻你 2020-12-07 17:52

I\'ve got a maven & spring app that I want logging in. I\'m keen to use SLF4J.

I want to put all my config files into a directory {classpath}/config including lo

7条回答
  •  感情败类
    2020-12-07 18:06

    In addition to Jatin's answer:

    Spring uses Jakarta Commons Logging as a logging API. In order to log to slf4j, you need to make sure commons-logging is not on the classpath. jcl-over-slf4j is a replacement jar for commons-logging.

    If you're using maven, you can detect where commons-logging comes from using mvn dependency:tree and exclude it from all dependencies that require it using dependency exclusions. You might need to run mvn dependency:tree several times though, because it only shows the first occurence of a transitive dependency.

    
      org.springframework
      spring-context
      ${org.springframework.version}
      
        
          commons-logging
          commons-logging
        
      
    
    

提交回复
热议问题