我的classpath中没有定义log4j2配置文件。我的日志消息仍然会进入控制台,我看不到有关丢失配置的警告。
我在Tomcat 7上运行基于servlet的应用程序。
我正在试图弄清楚它是如何获得这种配置的?
我希望在log4j2中看到警告,就像你在log4j中看到的一样。
答案 0 :(得分:1)
如果您不提供配置文件,Log4j2可以自动配置。
Log4j 2的配置可以通过以下四种方式之一完成:
http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration
答案 1 :(得分:1)
我正在使用Tomcat。当我删除log4j2.xml文件时这是我在Web服务器启动时看到的消息:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
由于严重性为ERROR,因此该消息确实非常可见。