简体   繁体   English

记录器名称的 Log4j2 转换模式

[英]Log4j2 conversion pattern for logger names

I'm trying to trim logger names in Log4j2 Core's PatternLayout .我正在尝试修剪 Log4j2 Core 的PatternLayout中的记录器名称。

Examples logger name:示例记录器名称:

com.test1.test2.test3.test4.test5.ClassName

Expected output:预期输出:

c.t.t.t.t.test5.ClassName

In the docs I can only trim from the end not from beginning.在文档中,我只能从结尾而不是从开头修剪。

Any suggestions would be helpful.任何的意见都将会有帮助。

Examples:例子:

    <Console name="ConsoleAppender" target="SYSTEM_OUT">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%p] %c{1.} %msg%xEx%n"/>
    </Console>

%c{1.} means output the first character of package name. %c{1.} 表示输出包名的第一个字符。

There is no pattern that allows you to abbreviate all components except the last two.没有模式允许您缩写除最后两个之外的所有组件。 This has been reported in LOG4J2-2785 and there is work in progress on this issue.这已在LOG4J2-2785中报告,并且正在处理此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM