Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
garydgregory opened this issue Oct 29, 2024 · 2 comments
Open

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

garydgregory opened this issue Oct 29, 2024 · 2 comments

Comments

@garydgregory
Copy link
Member

garydgregory commented Oct 29, 2024

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}
@ppkarwasz
Copy link
Contributor

There is problem in the documentation. Some time ago I wrote a SO answer based on the code. Can you fix the doc?

@ppkarwasz
Copy link
Contributor

In your case 1.2.* should mean: 1 character from the first component, 2 character from the second component, no restriction for the remaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants