【问题标题】:Wildfly 8 logging, how to truncate logger name from the left?Wildfly 8日志记录,如何从左侧截断记录器名称?
【发布时间】:2017-09-22 16:43:18
【问题描述】:

我的应用程序在 Wildfly 8.2.1 中运行。在standalone.xml 文件中,日志子系统配置为使用以下模式格式化程序:

        <console-handler name="CONSOLE">
            <formatter>
                <pattern-formatter pattern="%K{level}%d{yyyy-MM-dd HH:mm:ss,SSS} | %-5p | %-15.15t | %-30.30c | %s%n%e"/>
            </formatter>
        </console-handler>

当记录器的名称超过 30 个字符时,它会从右侧截断,如下行所示(完整的记录器名称为 com.fakeorg.test.gateway.polling.LongPollingMap):

2017-04-25 11:45:00,010 | DEBUG | EJB default - 1 | com.fakeorg.test.gateway.polli | Begin removing expired long-polling connections...

名称超过30个字符时如何从左边截断?

【问题讨论】:

    标签: java logging wildfly


    【解决方案1】:

    您想使用%-30.-30c。但是你会遇到truncation issue

    不过,您可以将 org.jboss.logmanager 模块替换为较新的版本。在 WildFly 11.0.0.Alpha1 之前,它看起来不像是正确版本的日志管理器进入 WildFly。

    要替换日志管理器的download 1.5.7.Final 所需的模块,请将其放在$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/ 目录中并编辑module.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.3" name="org.jboss.logmanager">
        <resources>
            <resource-root path="jboss-logmanager-1.5.7.Final.jar"/>
        </resources>
    
        <dependencies>
            <module name="javax.api"/>
            <module name="org.jboss.modules"/>
        </dependencies>
    </module>
    

    【讨论】:

    • 非常好。我不知道我是否真的要更换模块,因为过去我将代码从 JBossAS 迁移到 Wildfly 时遇到了麻烦,因为更换的模块和安装的自定义模块太多。
    • 在这种特殊情况下应该是相当安全的。
    猜你喜欢
    • 2014-12-03
    • 2021-09-01
    • 2015-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-26
    • 2014-06-19
    • 1970-01-01
    相关资源
    最近更新 更多