如何在运行时调整log4j级别? [英] How do I adjust log4j levels at runtime?

查看:135
本文介绍了如何在运行时调整log4j级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Tomcat 5.5上运行的简单Web应用程序,其中log4j用于记录。偶尔我需要将日志记录推送到DEBUG,但大多数时候我对INFO感到满意。

I have a simple web app running on Tomcat 5.5 with log4j for logging. Occasionally I need to push the logging down to DEBUG but most of the time I'm happy with INFO.

我可以更改我的配置xml并重新启动应用程序但我会喜欢动态切换日志级别。有没有标准的技术?

I can change my config xml and restart the app but I would prefer to switch the log levels on the fly. Is there a standard technique for this?

推荐答案

只需使用程序化的 API

logger.setLevel(Level.DEBUG)



<当您需要更详细的日志记录输出时,在您的程序中,

in your program when you need more verbose logging output, and

logger.setLevel(Level.INFO)

让它再次变得冗长。

这篇关于如何在运行时调整log4j级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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