在运行时打开/关闭日志 [英] Turning on/off logs at runtime

查看:200
本文介绍了在运行时打开/关闭日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SLF4J和Log4J进行日志记录。到目前为止,我正在使用xml文件中的log4j配置。如何在运行时打开/关闭日志记录。

I am using SLF4J with Log4J for logging. So far I am using the log4j configuration from xml file. How I can turn on/off logging at runtime.

例如。一个Web服务打开/关闭日志,所以我不会有太多日志,只会出于调试目的。

e.g. a web service turns on/off logs, so I will not have too much logs and will enable only for debugging purpose.

谢谢。

推荐答案

log4j记录器级别可以在运行时更改。将log4j日志记录级别更改为error,以便不记录所有debug和info语句。如果重新启动应用程序,则记录器级别将更改为log4j.xml或log4j.properties中定义的级别。

log4j logger levels can be changed at runtime. Change the log4j logging level to error, so that all the debug and info statements will no be logged. If the application is restarted the logger level will be changed to the one defined in log4j.xml or log4j.properties.

这篇关于在运行时打开/关闭日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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