如何在log4j2中以编程方式更改Appender布局?(How to change Appender layout programatically in log4j2?)

编程入门 行业动态 更新时间:2024-10-24 09:24:11
如何在log4j2中以编程方式更改Appender布局?(How to change Appender layout programatically in log4j2?)

以前在log4j 1.x中我能够appender.setLayout()和Appender,但现在在log4j 2.x中没有setLayout()这样的方法。 如何在log4j2中以编程方式将布局设置为Appender对象?

Previously in log4j 1.x I was able to to appender.setLayout() on and Appender but now in log4j 2.x there is no such method as setLayout(). How can I set a layout to an Appender object programatically in log4j2 ?

最满意答案

没有setLayout()方法。 您需要获取当前配置并在运行时更新它,如文档中所述。

There is no setLayout() method. You will need to get the current Configuration and update it during runtime as explained in the documentation.

更多推荐

本文发布于:2023-08-06 03:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中以   布局   方式   如何在   Appender

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!