Skip to content

Runtime or docs are wrong for %logger{1.2.*} #3140

@garydgregory

Description

@garydgregory

Description

Either the runtime or docs are wrong for layouts like %logger{1.2.*}.

The docs on page https://logging.apache.org/log4j/2.x/manual/pattern-layout.html say:

%c{1.2.*} | org.apache.commons.test.Foo | o.a.c.test.Foo

IOW, these docs say that only last 2 segments only are not abbreviated.

At runtime, in 2.24.1, I see, the opposite, the first 2 are abbreviated instead, for example

2024-10-29T09:50:57,046-0400 DEBUG [qtp1445038386-63][c.rs.seagull.httpmonitor.MyDomainClassName.50698c70] 865192895 async write complete of org.eclipse.jetty.ee9.proxy.MyDomainClassName$Chunk@76fdb2fc (17 bytes) on HttpOutput@7d59c816{s=OPEN,api=READY,sc=false,e=null}

How do I say I want to abbreviate everything except the last N?

Configuration

Version: 2.24.1

Microsoft Windows [Version 10.0.19045.5011]

openjdk version "17.0.12" 2024-07-16
OpenJDK Runtime Environment Temurin-17.0.12+7 (build 17.0.12+7)
OpenJDK 64-Bit Server VM Temurin-17.0.12+7 (build 17.0.12+7, mixed mode, sharing)

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: C:\java\apache-maven-3.9.9
Java version: 17.0.12, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.12.7-hotspot
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Docker version 27.3.1, build ce12230

Reproduction

      <PatternLayout noConsoleNoAnsi="false"
        pattern="%style{%d{ISO8601_OFFSET_DATE_TIME_HHMM}}{white} %highlight{%-5level}{TRACE=white} %style{[%t]}{yellow}%style{[%logger{1.2.*}]%notEmpty{[%markerSimpleName]}}{white} %highlight{%msg%n%xThrowable}{TRACE=white}" />

Logs

Same as above:

2024-10-29T09:50:57,046-0400 DEBUG [qtp1445038386-63][c.rs.seagull.httpmonitor.MyDomainClassName.50698c70] 865192895 async write complete of org.eclipse.jetty.ee9.proxy.MyDomainClassName$Chunk@76fdb2fc (17 bytes) on HttpOutput@7d59c816{s=OPEN,api=READY,sc=false,e=null}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions