让 log4j 在运行时了解配置的变化
我想知道是否有一种非编程方式使 log4j 在运行时了解配置的更改。我知道我可以
static {
PropertyConfigurator.configureAndWatch("log4j.properties", 100);
}
在一些有用的地方使用来监视属性文件的更改,但我更喜欢属性文件本身中的一个选项,告诉 log4j 监视更改。有吗?
I wonder if there is a non-programatical way of making log4j aware of changes on the configuration at runtime. I know I can use
static {
PropertyConfigurator.configureAndWatch("log4j.properties", 100);
}
at some useful place to watch a property file for changes, but I would prefer an option within the property file itself, to tell log4j watch for changes. Are there any ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Log4j 有一些 JMX 功能< /a> 这意味着您可以动态调整某些功能(特别是级别过滤)。
但我不相信你能做的比这更多。 Appender 没有生命周期的概念,他们可能需要能够在重新配置时可靠地打开/关闭资源。
Log4j has some JMX capabilities which means you can adjust some features dynamically (particularly filtering on level).
Howeever I don't believe you can do much more than that. Appenders have no concept of a lifecycle, which they'd likely need to be able to reliably open/close resources upon reconfiguration.