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

后端 未结 7 976
借酒劲吻你
借酒劲吻你 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:16

    Just add lazy-init="false" to eagerly load the bean for log4j configuration in your root context. That should solve the WARN message log4j:WARN No appenders could be found for logger

    Example:

    
    

    A more better approach would be to have the configuration in web.xml or as a JVM parameter (-Dlog4j.configuration=.../conf/log4j.xml or with 'file:' prefix as -Dlog4j.configuration=file:conf/log4j.properties for some cases)

提交回复
热议问题