如何在log4j2.xml中添加自定义appender

时间:2016-04-01 11:23:10

标签: java xml log4j2 perf4j

我有一个应用程序,我想使用perf4j。我想在log4j2.xml语法中已经改变了。在这里,我找不到为自定义appnder类声明类属性的方法。  我当前的log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="perf4j">
  <Appenders>
   <RollingFile name="RollingFile" fileName="/home/sarvesh/Desktop/log/perf4j.log" 
     filePattern="/home/sarvesh/Desktop/log/perf4j-%d{MM-dd-yyyy}.log">
      <PatternLayout>
        <Pattern>%d %p %c{1.} %m%n</Pattern>
      </PatternLayout>
      <TimeBasedTriggeringPolicy />
    </RollingFile>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    <Async name="rollingFileAppender">
      <AppenderRef ref="RollingFile"/>
    </Async>
    <Async name="consoleAppender">
      <AppenderRef ref="Console"/>
    </Async>
  </Appenders>
  <Loggers>
    <Root level="debug">
      <AppenderRef ref="rollingFileAppender"/>
      <AppenderRef ref="consoleAppender"/>
    </Root>
  </Loggers>
</Configuration>

现在我想添加几个appender,比如

<appender name="CoalescingStatistics"
                   class="org.perf4j.log4j.AsyncCoalescingStatisticsAppender">
            <!--
              The TimeSlice option  means timing logs are aggregated every 10 secs.
            -->
            <param name="TimeSlice"  value="10000"/>
            <appender-ref  ref="fileAppender"/>
            <appender-ref  ref="perf4jJmxAppender"/>
        </appender>

如何在log4j2.xml中添加此appender

0 个答案:

没有答案