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

查看:37
本文介绍了禁用 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天全站免登陆