gpt4 book ai didi

java - Log4j2:没有可用的 log4j-web 模块

转载 作者:搜寻专家 更新时间:2023-10-31 19:44:10 27 4
gpt4 key购买 nike

我试图将我的配置的状态级别设置为“信息”,但我得到以下输出:

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.

我的 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>

我已经下载了 log4j-web-2.6.2.jar文件并将其添加到我的类路径中,但由于某种原因我仍然得到相同的输出。我做错了什么?我能够输出 DEBUG 状态级别,但不能输出 INFO,这很奇怪。

最佳答案

起初,我认为问题是因为我的类路径中有我需要的 servlet-api jar,但删除它并没有解决问题,对我来说。最后,我所要做的就是添加来自 mvnrepositorylog4 web jar 文件。到你的类路径,你就设置好了!

关于java - Log4j2:没有可用的 log4j-web 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39420059/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com