我将Log4j从2.9.1升级到2.13.2。升级后,启动tomcat服务器时会显示大量不必要的日志。
DEBUG StatusLogger Using ShutdownCallbackRegistry class org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
INFO StatusLogger 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.
INFO StatusLogger 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.
DEBUG StatusLogger Took 0.319733 seconds to load 239 plugins from ParallelWebappClassLoader
context: ROOT
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@6d78f375
DEBUG StatusLogger PluginManager 'Converter' found 46 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger Starting LoggerContext[name=531f4093, org.apache.logging.log4j.core.LoggerContext@144283f3]...
DEBUG StatusLogger Reconfiguration started for context[name=531f4093] at URI null (org.apache.logging.log4j.core.LoggerContext@144283f3) with optional ClassLoader: null
INFO StatusLogger 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.
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=StatusLogger'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=ContextSelector'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=Loggers,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=Appenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=AsyncAppenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=AsyncLoggerRingBuffer'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=531f4093,component=Loggers,name=*,subtype=RingBuffer'如何处理所有这些伐木?
我的log4j看起来就像
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<!-- ********************** Concole **************************-->
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%t %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
<ThresholdFilter level="OFF"/>
</Console>
<!-- other file appenders and loggers-->
<!-- ********************************* Root ************************************ -->
<Root level="INFO">
<AppenderRef ref="console"/>
<AppenderRef ref="async_file"/>
<AppenderRef ref="async_errors_file" level="WARN"/>
</Root>
</Loggers>
</Configuration> 我和<Configuratin status="WARN/OFF">试过了,但没有起作用。
我有以下依赖项
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>请建议什么是解决这个问题的方法?
发布于 2020-06-05 09:20:39
来自Log4j文档:
From log4j-2.9 onward, log4j2 will print all internal logging to the console
if system property log4j2.debug is defined (with any or no value).检查您是否声明了-Dlog4j2.debug或-Dlog4j.debug,就像这样。在我的例子中,正如他们在doc中提到的那样,它没有任何价值,我将其更改为-Dlog4j.debug="ERROR"。现在,问题解决了,没有打印内部日志。
发布于 2022-10-11 02:11:55
-DLOG4J-LEVEL=INFO试一下
https://stackoverflow.com/questions/62169830
复制相似问题