javalog4j2perf4j

How to configure StatisticsCsvLayout in log4j2


Need help from migrating log4j to log4j2. I have a rollingFileAppender. I need this appender to make use of "StatisticsCsvLayout" in org.perf4j. Previously in log4j 1.x version we used to directly refer the StatisticsCsvLayout from any appender using following tag in log4j.xml.

<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. Please tell me how to configure this in log4j2.xml.


Solution

  • 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). 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.

    link

    Thanks to @Remko Popma for the help. :)