I am trying to set the status level of my config to "info", but I am getting the following output:
我试图将配置的状态级别设置为“info”,但我得到了以下输出:
INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
My log4j2.xml has the following
我的log4j2。xml具有以下
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" packages="org.graylog2.log4j2">
<Properties>
<Property name="default_pattern">%d{MM/dd/yyyy hh:mm:ss} %5p %c{1} - %m%n</Property>
</Properties>
<!-- LOG4J2 APPENDERS -->
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="com.sum.exam" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="auth" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="com.d.e" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="com.google.gson" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="org.elasticsearch" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<Console name="com.datamotion.direct" target="SYSTEM_OUT">
<PatternLayout pattern="${default_pattern}"/>
</Console>
<NullAppender name="null">
<PatternLayout pattern="${default_pattern}"/>
</NullAppender>
<!-- GELFJ CONFIGURATION -->
<GELF name="gelfAppender"
server="org.graylog2.log.GelfAppender"
port="12201"
hostName="logs.x.d.com"
facility="GELF-JAVA"
additionalFields="{'\u2018environment\u2019\': '\u2018EHR\u2019'}"
extractStacktrace="true"
addExtendedInformation="true">
<PatternLayout pattern="${default_pattern}"/>
<Root level="info">
<AppenderRef ref="gelfAppender" level="info"/>
</Root>
</GELF>
</Appenders>
<!-- LOG4J2 CONFIGURATION -->
<Loggers>
<Root level="error" additivity="false" />
<Logger name="console" level="info">
<AppenderRef ref="console" />
</Logger>
<Logger name="com.sum.exam" level="debug" additivity="false">
<AppenderRef ref="com.sum.exam" />
</Logger>
<Logger name="auth" level="debug" additivity="false">
<AppenderRef ref="auth" />
</Logger>
<Logger name="com.d.e" level="debug" additivity="false">
<AppenderRef ref="com.d.e" />
</Logger>
<Logger name="com.google.gson" level="info">
<AppenderRef ref="com.google.gson" />
</Logger>
<Logger name="org.elasticsearch" level="info">
<AppenderRef ref="org.elasticsearch" />
</Logger>
<Logger name="com.datamotion.direct" level="debug" additivity="false">
<AppenderRef ref="com.datamotion.direct" />
</Logger>
</Loggers>
</Configuration>
I have download the jar file (log4j-web-2.6.2.jar) and added it to my class path, but I still get the same output for some reason. What could I be doing wrong? I am able to output DEBUG status levels, but not INFO which is odd.
我已经下载了jar文件(log4j-web-2.6.2.jar)并将它添加到我的类路径中,但是出于某些原因,我仍然得到相同的输出。我做错了什么?我能够输出调试状态级别,但不能够输出奇怪的信息。
2 个解决方案
#1
3
At first, I thought the problem was because I have servlet-api jar in my classpath, which I need, but removing that did not fix the problem, for me. In the end, all I had to do was just add the log4 web jar file from mvnrepository to your classpath and you're set!
一开始,我认为问题在于我的类路径中有servlet-api jar,这是我需要的,但是对我来说,删除它并不能解决问题。最后,我所要做的就是将来自mvnrepository的log4 web jar文件添加到您的类路径中,您就完成了!
#2
0
The status="info"
at the beginning of the configuration file is for internal log4j2 debug messages. If you set it to trace you will see details on how log4j2 is configured.
配置文件开头的状态=“info”用于内部log4j2调试消息。如果将其设置为trace,您将看到关于如何配置log4j2的详细信息。
That has nothing to do with your application logging though. You say you are able to output debug messages, I assume that mean that the logging itself works as expected (If there's a problem there then please show your full configuration. )
但这与应用程序日志无关。您说您可以输出调试消息,我假设这意味着日志记录本身可以正常工作(如果存在问题,请显示您的完整配置)。
#1
3
At first, I thought the problem was because I have servlet-api jar in my classpath, which I need, but removing that did not fix the problem, for me. In the end, all I had to do was just add the log4 web jar file from mvnrepository to your classpath and you're set!
一开始,我认为问题在于我的类路径中有servlet-api jar,这是我需要的,但是对我来说,删除它并不能解决问题。最后,我所要做的就是将来自mvnrepository的log4 web jar文件添加到您的类路径中,您就完成了!
#2
0
The status="info"
at the beginning of the configuration file is for internal log4j2 debug messages. If you set it to trace you will see details on how log4j2 is configured.
配置文件开头的状态=“info”用于内部log4j2调试消息。如果将其设置为trace,您将看到关于如何配置log4j2的详细信息。
That has nothing to do with your application logging though. You say you are able to output debug messages, I assume that mean that the logging itself works as expected (If there's a problem there then please show your full configuration. )
但这与应用程序日志无关。您说您可以输出调试消息,我假设这意味着日志记录本身可以正常工作(如果存在问题,请显示您的完整配置)。