Log4j配置和监视无法正常工作 [英] Log4j configure and watch not working properly
问题描述
我在我的应用程序中将log4j用于登录目的.从现在开始配置日志记录,我一直在使用以下代码:
I am using log4j for loggin purpose in my application. Since now to configure the logging i was using the following code :
LogManager.resetConfiguration();
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("log4j.properties");
Properties props= new Properties();
props.load(stream);
PropertyConfigurator.configure(props);
但是问题是,只要我想在此过程中更改日志记录级别,就必须重新启动服务器.所以我将代码更改为:-
But the problem with this was , that whenever i wanted to change the logging level during the process, i had to restart the server. So i changed the code to :-
LogManager.resetConfiguration();
PropertyConfigurator.configureAndWatch(("log4j.properties", 900000L);
理想情况下,此代码应有助于在指定的时间(我已提到15分钟)之后重新加载log4j.properties文件.但是代码仍然无法正常工作
this code ideally should help to re-load the log4j.properties file after the time specified, which i have mentioned as 15 minutes. But still the code is not working
我在代码过程中缺少东西吗?
Am i missing somthing during the code?
致谢.
推荐答案
configureAndWatch()
监视文件.不是类路径中的资源.
configureAndWatch()
watches files. Not resources in the classpath.
这篇关于Log4j配置和监视无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!