How to initialize log4j properly?

前端 未结 24 3594
太阳男子
太阳男子 2020-11-22 06:49

After adding log4j to my application I get the following output every time I execute my application:

log4j:WARN No appenders could be found for logger (slideselec         


        
24条回答
  •  佛祖请我去吃肉
    2020-11-22 07:17

    If we are using apache commons logging wrapper on top of log4j, then we need to have both the jars available in classpath. Also, commons-logging.properties and log4j.properties/xml should be available in classpath.

    We can also pass implementation class and log4j.properties name as JAVA_OPTS either using -Dorg.apache.commons.logging.Log= -Dlog4j.configuration=. Same can be done via setting JAVA_OPTS in case of app/web server.

    It will help to externalize properties which can be changed in deployment.

提交回复
热议问题