如何禁用 Spring 日志以获得我可以轻松阅读或其他人可以阅读的日志输出。
一个类似问题的答案,how to disable spring bean loading log建议注释掉 log4j.properties
file
中所有具有 org.springframework
substring
的行。就我而言,没有这样的行。
这里是 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
最佳答案
对于未明确指定的所有内容,您的默认日志记录是DEBUG。所以一切都记录在那个级别(从你的配置来看),基本上你正在淹没你的日志。您不应该删除 org.springframework 的记录器,您应该添加它们并为它们设置另一个级别。
log4j.logger.org.springframework=INFO
或您喜欢的任何日志级别。
https://stackoverflow.com/questions/18648014/