禁用Spring日志以获取可读日志 [英] Disabling Spring log, to have readable logs

查看:60
本文介绍了禁用Spring日志以获取可读日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I disable Spring logs to have log outputs that I can easily read or someone else can read. An answer to a similar question at, how to disable spring bean loading log suggested to comment out all lines having org.springframework substring in log4j.properties file. In my case there no such lines.

这是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的记录器,而应该添加它们并为其设置另一个级别.

Your default logging, for everything that isn't explictily specified, is DEBUG. So everything is logged at that level (judging from your configuration), basically you are flooding your logs. You should not remove loggers for org.springframework you should add them and set another level for them.

log4j.logger.org.springframework=INFO 

或您喜欢的任何日志级别.

or whatever log level level you like.

这篇关于禁用Spring日志以获取可读日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆