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

编程入门 行业动态 更新时间:2024-10-17 15:32:05
本文介绍了禁用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.springframework=INFO

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

or whatever log level level you like.

更多推荐

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

本文发布于:2023-11-24 04:43:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日志   可读   Spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!