Log4j:使用 DOMConfigurator 更改 XML?

发布于 2024-09-04 04:21:05 字数 322 浏览 1 评论 0原文

我正在将 log4j 与 Java 一起使用,并且想要配置我的 XML 配置文件(我需要将 XML 用于 ErrorHandler),以便可以在 DOMConfigurator 中更改 XML 中的某些属性(例如 RollingFileAppender 的备份值) log4j-API 的。这个类还具有 subst() 方法,该方法应该替换所选的值,但我真的不知道如何处理它。

如果他们无法使用 DOMConfigurator 更改配置,那么我还有哪些可能性可以轻松地纠正不明确的 XML 文件中的值(也就是说,因为 XML 标签不是唯一的,或者只是它们的标签名称,它们是值本身)?我的 XML 是静态的或手写的。

I am using log4j with Java and wanted to configure my XML-Config-File (I need to use XML for the ErrorHandler), so that some Properties in the XML (like the Backup-Value for the RollingFileAppender) could be changed within the DOMConfigurator of the log4j-API. This class also got the subst()-method, which should substitute the chosen values, but I really don´t know how to handle it.

If their is no way changing the config with the DOMConfigurator, which else possibilities did I got to easily correct values in an ambiguous XML-File (So to say, because the XML-Tags are not unique or only their Tag-names, which are values itself)? My XML is kind of static or hand-written.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

归途 2024-09-11 04:21:05

为什么不能修复磁盘上的原始 XML 文件?

如果由于某种原因这是不可能的,我宁愿在加载配置文件后尝试通过 Logger 直接更改配置。

Why can't you fix the original XML file on the disk?

If for some reason that's not possible, I would rather try altering the configuration directly via Logger, after the config file has been loaded.

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