Log4j:使用 DOMConfigurator 更改 XML?
我正在将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不能修复磁盘上的原始 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.