2016-06-07 223 views
1

以下是log4j 1.x中使用的示例。我没有得到任何例子来转换在log4j2相同。如何在log4j2中使用org.perf4j.log4j.AsyncCoalescingStatisticsAppender?

<appender name="CoalescingStatisticsAppender" 
    class="org.perf4j.log4j.AsyncCoalescingStatisticsAppender"> 
    <!-- 
     The TimeSlice option is used to determine the time window for which 
     all received StopWatch logs are aggregated to create a single 
     GroupedTimingStatistics log. Here we set it to 10 seconds, overriding 
     the default of 30000 ms 
    --> 
    <param name="TimeSlice" value="30000" /> 
    <appender-ref ref="perf4jFileAppender" /> 
</appender> 

回答

1

Appender在Log4j 2中不能正常工作,它必须被重写。

+0

你能解释我该怎么写吗? –

0

您可能有兴趣知道Log4j 2支持PatternLayout中的nanoTime时间戳。这与低开销异步记录器结合使用,可以将Log4j用作粗略的分析工具。

+0

这也是一回事,但主要查询是关于如何使用与log4j2.xml中相同的appender。如果我通过查看lo4j2文档正确理解,我需要为它创建一个插件。所有的例子都在扩展一个appender。在我的情况下,我想这将是AsyncCoalescingStatisticsAppender,但绝对不会支持构造函数。请详细说明。 –