logback.xml的perf4j设置 [英] perf4j settings for logback.xml

查看:116
本文介绍了logback.xml的perf4j设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我想知道在使用perf4j时logback.xml的确切配置设置。
我在logback.xml中创建此配置

hi folks I want to know exact config settings of logback.xml when it was using with perf4j. i create this configuration in logback.xml

<configuration>
    <!-- Perf4J appenders -->
    <!--
       This AsyncCoalescingStatisticsAppender groups StopWatch log messages
       into GroupedTimingStatistics messages which it sends on the
       file appender defined below
    -->
    <appender name="CoalescingStatistics" class="org.perf4j.logback.AsyncCoalescingStatisticsAppender">
        <param name="TimeSlice" value="60000"/>
        <appender-ref ref="graphExecutionTimes"/>
        <appender-ref ref="graphExecutionTPS"/>
        <!-- We add the JMX Appender reference onto the CoalescingStatistics -->
        <appender-ref ref="perf4jJmxAppender"/>
    </appender>

    <appender name="graphExecutionTimes" class="org.perf4j.logback.GraphingStatisticsAppender">
        <!-- Possible GraphTypes are Mean, Min, Max, StdDev, Count and TPS -->
        <param name="GraphType" value="Mean"/>
        <!-- The tags of the timed execution blocks to graph are specified here -->
        <param name="TagNamesToGraph" value="DESTROY_TICKET_GRANTING_TICKET,GRANT_SERVICE_TICKET,GRANT_PROXY_GRANTING_TICKET,VALIDATE_SERVICE_TICKET,CREATE_TICKET_GRANTING_TICKET" />
    </appender>

    <appender name="graphExecutionTPS" class="org.perf4j.logback.GraphingStatisticsAppender">
        <param name="GraphType" value="TPS" />
        <param name="TagNamesToGraph" value="DESTROY_TICKET_GRANTING_TICKET,GRANT_SERVICE_TICKET,GRANT_PROXY_GRANTING_TICKET,VALIDATE_SERVICE_TICKET,CREATE_TICKET_GRANTING_TICKET" />
    </appender>

    <!--
      This JMX appender creates an MBean and publishes it to the platform MBean server by
      default.
    -->
    <appender name="perf4jJmxAppender" class="org.perf4j.logback.JmxAttributeStatisticsAppender">
        <!--
          You must specify the tag names whose statistics should be exposed as
          MBean attributes.
        -->
        <TagNamesToExpose>firstBlock,secondBlock</TagNamesToExpose>
        <!--
          The NotificationThresholds param configures the sending of JMX notifications
          when statistic values exceed specified thresholds. This config states that
          the firstBlock max value should be between 0 and 800ms, and the secondBlock max
          value should be less than 1500 ms. You can also set thresholds on the Min,
          Mean, StdDev, Count and TPS statistics - e.g. firstBlockMean(<600).

        <NotificationThresholds>firstBlockMax(0-800),secondBlockMax(<1500)</NotificationThresholds>-->
        <!--
          You can also specify an optional MBeanName param, which overrides
          the default MBean name of org.perf4j:type=StatisticsExposingMBean,name=Perf4J
        -->
    </appender>

    <!-- Loggers -->
    <!--
      The Perf4J logger. Note that org.perf4j.TimingLogger is the value of the
      org.perf4j.StopWatch.DEFAULT_LOGGER_NAME constant. Also, note that
      additivity is set to false, which is usually what is desired - this means
      that timing statements will only be sent to this logger and NOT to
      upstream loggers.
    -->
    <logger name="org.perf4j.TimingLogger" additivity="false">
        <level value="INFO"/>
        <appender-ref ref="CoalescingStatistics"/>
        <appender-ref ref="perf4jFileAppender"/>
    </logger>

    <!-- This file appender is used to output aggregated performance statistics -->
    <appender name="perf4jFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>logs/perf4j.log</File>
        <encoder>
            <Pattern>%date %-5level [%thread] %logger{36} [%file:%line] %msg%n</Pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>logs/perf4j.%d{yyyy-MM-dd}.log</FileNamePattern>
        </rollingPolicy>
    </appender>
</configuration>

我从perf4j logback文档中得到了它。因此,当我尝试使用此logback conf时,它不会通过任何异常,但它会打印一些奇怪的语句,这些语句在下面给出了


i got it from perf4j logback documentation . So when i tried to use this logback conf it tdidn't through any exception but it prints some strange statements which are given below

18:26:19,945 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
18:26:19,945 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
18:26:19,945 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/ifkaar/Backup/eclipse/workspace/Perf4jTestProject/bin/logback.xml]
18:26:20,245 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
18:26:20,263 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.perf4j.logback.AsyncCoalescingStatisticsAppender]
18:26:20,308 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CoalescingStatistics]
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [graphExecutionTimes]. Did you define it below in the config file?
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [graphExecutionTPS]. Did you define it below in the config file?
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [perf4jJmxAppender]. Did you define it below in the config file?
18:26:20,462 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
18:26:20,471 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.perf4j.logback.GraphingStatisticsAppender]
18:26:20,506 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [graphExecutionTimes]
18:26:20,535 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.perf4j.logback.GraphingStatisticsAppender]
18:26:20,535 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [graphExecutionTPS]
18:26:20,538 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [org.perf4j.logback.JmxAttributeStatisticsAppender]
18:26:20,554 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [perf4jJmxAppender]
18:26:20,913 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.perf4j.TimingLogger] to false
18:26:20,914 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.perf4j.TimingLogger level set to INFO
18:26:20,914 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CoalescingStatistics] to Logger[org.perf4j.TimingLogger]
18:26:20,914 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [perf4jFileAppender]. Did you define it below in the config file?
18:26:20,914 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
18:26:20,914 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
18:26:20,930 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [perf4jFileAppender]
18:26:20,962 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
18:26:21,136 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used
18:26:21,141 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern logs/perf4j.%d{yyyy-MM-dd}.log for the active file
18:26:21,151 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern 'logs/perf4j.%d{yyyy-MM-dd}.log'.
18:26:21,151 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
18:26:21,158 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Thu May 31 18:26:21 PKT 2012
18:26:21,161 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[perf4jFileAppender] - Active log file name: logs/perf4j.log
18:26:21,161 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[perf4jFileAppender] - File property is set to [logs/perf4j.log]

enter code here


推荐答案

错误信息非常具有描述性:

The error message is very descriptive:


18:26:20,462 | -ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - 找不到名为[ graphExecutionTimes ]的追加程序。 您是否在配置文件中定义了以下内容?

[...]

18:26:20,506 | -INFO in ch.qos.logback.core.joran.action.AppenderAction - 将appender命名为[ graphExecutionTimes ]

18:26:20,506 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [graphExecutionTimes]

错误消息明确地问你:你在配置文件中定义了下面的[graphExecutionTimes] appender吗?事实上,就是这种情况,如上所示。只需切换这些声明:

The error message explicitly asks you: Did you define [graphExecutionTimes] appender below in the config file? And in fact, this is the case, as shown above. Just switch these declarations:

<appender name="graphExecutionTimes" class="org.perf4j.logback.GraphingStatisticsAppender">
    <!-- Possible GraphTypes are Mean, Min, Max, StdDev, Count and TPS -->
    <param name="GraphType" value="Mean"/>
    <!-- The tags of the timed execution blocks to graph are specified here -->
    <param name="TagNamesToGraph" value="DESTROY_TICKET_GRANTING_TICKET,GRANT_SERVICE_TICKET,GRANT_PROXY_GRANTING_TICKET,VALIDATE_SERVICE_TICKET,CREATE_TICKET_GRANTING_TICKET" />
</appender>

<appender name="graphExecutionTPS" class="org.perf4j.logback.GraphingStatisticsAppender">
    <param name="GraphType" value="TPS" />
    <param name="TagNamesToGraph" value="DESTROY_TICKET_GRANTING_TICKET,GRANT_SERVICE_TICKET,GRANT_PROXY_GRANTING_TICKET,VALIDATE_SERVICE_TICKET,CREATE_TICKET_GRANTING_TICKET" />
</appender>

<appender name="CoalescingStatistics" class="org.perf4j.logback.AsyncCoalescingStatisticsAppender">
    <param name="TimeSlice" value="60000"/>
    <appender-ref ref="graphExecutionTimes"/>
    <appender-ref ref="graphExecutionTPS"/>
    <!-- We add the JMX Appender reference onto the CoalescingStatistics -->
    <appender-ref ref="perf4jJmxAppender"/>
</appender>

以防万一将 perf4jFileAppender 移至顶部同样。如果此代码段来自Perf4J文档,您应该要求作者修复它。

Just in case move perf4jFileAppender to the top as well. If this code snippet comes from Perf4J documentation, you should ask the authors to fix it.

这篇关于logback.xml的perf4j设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆