简体   繁体   English

如何在log4j2中配置StatisticsCsvLayout

[英]How to configure StatisticsCsvLayout in log4j2

Need help from migrating log4j to log4j2. 需要从log4j迁移到log4j2的帮助。 I have a rollingFileAppender. 我有一个rollingFileAppender。 I need this appender to make use of "StatisticsCsvLayout" in org.perf4j. 我需要此附加程序来使用org.perf4j中的“ StatisticsCsvLayout”。 Previously in log4j 1.x version we used to directly refer the StatisticsCsvLayout from any appender using following tag in log4j.xml. 以前在log4j 1.x版本中,我们曾经使用log4j.xml中的以下标记直接从任何附加程序引用StatisticsCsvLayout。

<Layout class='org.perf4j.log4j.StatisticsCsvLayout'/>

We are unable to confire this from log4j2.xml as we are not able to make use of external layouts directly. 由于我们无法直接使用外部布局,因此无法从log4j2.xml取消此操作。 Please tell me how to configure this in log4j2.xml. 请告诉我如何在log4j2.xml中进行配置。

If the org.perf4j StatisticsCsvLayout is not directly compatible with log4j2, you may need to create your own (or convince the perf4j people to port this layout to log4j2). 如果org.perf4j StatisticsCsvLayout与log4j2不直接兼容,则可能需要创建自己的(或说服perf4j人员将此布局移植到log4j2)。 Fortunately creating a custom layout is not very difficult. 幸运的是,创建自定义布局不是很困难。 Here is some sample code. 这是一些示例代码。 You can also look at the log4j2 source code for more details, like how to pass parameters. 您也可以查看log4j2源代码以获取更多详细信息,例如如何传递参数。

link 链接

Thanks to @Remko Popma for the help. 感谢@Remko Popma的帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM