让 log4j 在运行时了解配置的变化

发布于 2024-08-18 04:40:16 字数 216 浏览 3 评论 0原文

我想知道是否有一种非编程方式使 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘东忘西忘不掉你 2024-08-25 04:40:16

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文