Java Log4j2-除Spring之外的调试级别日志记录
我希望我的应用程序在调试级别运行,但Spring除外,它会生成大量日志语句,这使得很难读取日志。我目前已将Log4j2文件配置为:Java Log4j2-除Spring之外的调试级别日志记录,java,spring,log4j,log4j2,Java,Spring,Log4j,Log4j2,我希望我的应用程序在调试级别运行,但Spring除外,它会生成大量日志语句,这使得很难读取日志。我目前已将Log4j2文件配置为: <Configuration status="debug"> <Appenders> <RollingFile name="systemLog" fileName="C:/test/logs/system.log" includeLocation="true" filePa
<Configuration status="debug">
<Appenders>
<RollingFile name="systemLog" fileName="C:/test/logs/system.log" includeLocation="true"
filePattern=""C:/test/logs/system-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout pattern="%d{ISO8601} - %-5level [%t] %C %M %m%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="15 MB"/>
</Policies>
</RollingFile>
<Async name="systemAsyncAppender" includeLocation="true">
<AppenderRef ref="systemLog" />
</Async>
</Appenders>
<Loggers>
<SpringLogger name="org.springframework.*" level="error" additivity="false">
<AppenderRef ref="systemAsyncAppender" />
</SpringLogger>
<Root level="debug" includeLocation="true">
<AppenderRef ref="systemAsyncAppender" />
</Root>
</Loggers>
</Configuration>
我不认为log4j2对Spring有任何特殊的配置,因此
在这里似乎不合适
相反,只需声明一个常规记录器
<logger name="org.springframework" level="error" additivity="false">
...
</logger>
...
还要注意记录器名称。这些是分级的。您不需要*
(我认为它实际上破坏了它)。我在任何地方都没有看到
元素。为什么不用name=“org.springframework”
(注意:没有*
)声明一个正常的
?@SotiriosDelimanolis:/facepalm
耶。。。就这样。出于某种原因,我认为需要为记录器提供自己的元素名称。笨蛋!:P你的建议奏效了,所以如果你写下来作为回答,我会接受的。