logback.xml 的 perf4j 设置

2023-12-01

大家好,我想知道 logback.xml 与 perf4j 一起使用时的确切配置设置。 我在 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 时,它没有出现任何异常,但它打印了一些奇怪的语句,如下所示

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

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

18:26:20,462 |-ch.qos.logback.core.joran.action.AppenderRefAction 中出现错误 - 找不到名为 [ 的附加程序图执行时间]. 您是否在配置文件中定义了它?

[...]

18:26:20,506 |-ch.qos.logback.core.joran.action.AppenderAction 中的信息 - 将附加程序命名为 [图执行时间]

错误消息明确询问您:您是否在配置文件中定义了下面的 [graphExecutionTimes] 附加程序?而事实上,情况确实如此,如上图所示。只需切换这些声明:

<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 文档,您应该要求作者修复它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

logback.xml 的 perf4j 设置 的相关文章

随机推荐

  • 使用优先级队列合并 K 排序列表

    我在算法课上被要求制作一个 K 路合并算法 其大小为O nlogk 搜索后 我发现可以通过创建一个 k 长度的优先级队列并将其与每个列表的第一个元素排队来完成 提取最小值 将其附加到结果中 并从已提取元素的列表中排队 我很困惑 它如何知道特
  • Android Wear 上的加速计会耗尽电池电量吗? (安卓手表)

    我正在创建一个 Android Wear 应用程序 尝试检测一些手部动作 为此 我需要持续监控加速度计输出 我想知道这将如何影响电池寿命 对于手机 我知道有 屏幕关闭时禁用加速计 之类的方法来节省电池 但是手表的电池成本是多少 由于Andr
  • 如何获取文件列表作为 Jgit 提交的一部分

    我想获取属于提交一部分的所有文件的列表 我有可用的提交 ID 我查看了以下链接 如何使用 JGit 获取提交的文件列表 并尝试了以下代码 TreeWalk treeWalk new TreeWalk repository treeWalk
  • 用完 0 型蹦床

    我正在使用 Monotouch 为 Iphone 编写一个应用程序 当我在 iPhone 上部署应用程序时 我在运行时收到错误 Thu Mar 10 23 38 36known UIKitApplication com xxx 0x57b4
  • 控制器处理程序方法支持的返回类型

    在学习Spring框架的时候 我在书上注意到春天在行动 作者没有使用ModelandView控制器中的方法返回类型 作者将控制器方法声明为返回类型String该方法中的 return 子句只是返回一个字符串 例如return views t
  • C 中 strncpy 的内存混乱

    本周我的同事讨论了一个关于内存的问题 示例代码1 int main define Str This is String char dest 1 char buff 10 strncpy dest Str sizeof Str printf
  • 尽管驱动程序位于 /usr/local/bin 中,Selenium“无法找到匹配的功能集”

    我试图使用 selenium webdriver 打开 Firefox 浏览器 我已经有了我的 geckodriver usr local bin因为我正在从事网络抓取和爬行项目 Geckodriver 版本 21 0 Firefox 版本
  • “找不到内容安全策略元标记。”我的phonegap应用程序出现错误

    在我的系统中更新 Cordova 5 0 后 我创建了新的应用程序 当我在设备上测试我的应用程序时 我在控制台日志中收到错误 No Content Security Policy meta tag found Please add one
  • 检查字符串并将其转换为日期 vb.net

    我是 VB NET 的初学者 我陷入了一个非常简单的问题 即日期格式 我正在开发一个应用程序 它将数据从 Excel 工作表上传到 SQL Server 数据库 应用程序仅接受 mm dd yyyy 格式的日期 否则它应该拒绝所有日期 现在
  • 如何制作 Makefile 将命令及其输出记录到文件中?

    我想将命令及其输出记录到日志文件中 看起来很容易 只需将标准输出重定向到日志文件即可 myrule mycommand gt gt logfile 但这仅记录命令的输出 不是命令本身 我是否还回显该命令并将输出重定向到日志文件 myrule
  • 什么是“近空”类?

    编译下面的类 class Interface virtual void doIt 0 virtual Interface 0 inline Interface Interface using gcc fdump class hierarch
  • 我可以在 PowerPivot 中比较相邻行中同一列中的值吗?

    我有一个 PowerPivot 表 我需要能够确定某个项目处于错误状态的时间 我的数据集看起来像这样 我需要做的是查看 ID 和 State 列中的值 并查看 State 列中前一行的值是否为 ERROR 以及 ID 列中的值是否相同 如果
  • 如何在JavaScript值分配中分配php变量? [复制]

    这个问题在这里已经有答案了 可能的重复 如何将 JavaScript 变量传递给 PHP 如何在此 php 变量上分配 javascript 值 你根本无法做到这一点 你需要了解客户端 服务器端编程之间的区别 你不能将 Javascript
  • CORBA 通信问题

    这可能太本地化了 但我希望有人能帮助我正确地阐明我的问题 因此 我们有一个前端 Web 服务器 它使用 CORBA 与后端应用程序服务器进行通信 我被要求将后端应用程序移植到 LINUX 机器上 我照做了 但是 为了测试它 我尝试将前端 W
  • 从 Applet 打印 JasperReport

    我开发了网络应用程序 它使用JasperReports用于报告目的 因为我必须使用小程序在客户端查看报告 我可以正常在小程序中看到报告 但是当涉及到打印时 当我单击查看器中的 打印 按钮时 它会抛出一个异常 我可以在 Java 控制台中看到
  • 基于频率水平的子集[重复]

    这个问题在这里已经有答案了 我想生成一个 df 它选择与 ID 关联的行 而 ID 又与名为 cutoff 的变量关联 对于本示例 我将截止值设置为 9 这意味着我要选择 df1 中 ID 值与超过 9 行关联的行 我的代码的最后一行生成了
  • 如何在 asp.net 中使用“Post/Redirect/Get”(又名“Redirect after Post”)

    在 asp net 中的某些操作之后进行刷新似乎会使它们再次发生 即使该操作没有意义 想想双重删除 处理这种情况的 Web 方法是在发布后重定向以获得可以刷新的页面的干净版本 而无需将操作重新发布到 Web 服务器 我怎样才能用 ASP N
  • 接受带有自签名证书的 HTTPS 连接

    我正在尝试使用 HTTPS 连接HttpClientlib 但问题是 由于证书不是由公认的证书颁发机构 CA 签署的 例如Verisign 全局标志等 列在 Android 可信证书集中 我不断收到javax net ssl SSLExce
  • 如何通过标题而不是绘图区域来对齐多个绘图?

    我在用着egg对齐页面上的多个绘图 我想知道是否可以通过标题对齐两列a and c 而不是情节面积 谢谢 Code library egg library grid p1 lt ggplot mtcars aes mpg wt colour
  • logback.xml 的 perf4j 设置

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