小编典典

禁用Spring日志以获取可读日志

spring

我如何禁用Spring日志以使其具有我可以轻松阅读或其他人可以阅读的日志输出。关于如何禁用spring bean加载日志的类似问题的答案建议注释掉org.springframework substringin中的所有行log4j.properties file。就我而言,没有这样的行。

这是 log4j.properties

# Define the root logger with appender file
log4j.rootLogger = DEBUG, stdout

# Define the file appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Set the name of the logs destination
log4j.appender.stdout.target=System.out

# Set the immediate flush to true (default)
log4j.appender.stdout.ImmediateFlush=true

# Set the threshold to debug mode
log4j.appender.stdout.Threshold=debug

# Set the append to false, overwrite
log4j.appender.stdout.Append=false

# Define the layout for appender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%d{yyyy-MM-dd}:%m%n 

阅读 285

收藏
2020-04-20

共1个答案

小编典典

对于未明确指定的所有内容,默认日志记录为DEBUG。因此,所有内容都记录在该级别(根据你的配置判断),基本上,你正在泛滥日志。你不应删除org.springframework的记录器,而应添加它们并为其设置另一个级别。

log4j.logger.org.springframework=INFO 

或你喜欢的任何日志级别。

2020-04-20