apache / apache/logging-log4j2

Logger precision formats in PatternLayout do not match documentation

Open
#2,522 0 comments 0 reactions 0 assignees View on GitHub
bug layouts
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

## Description

In the docs at https://logging.apache.org/log4j/2.x/manual/layouts.html#patterns it gives an example pattern `%c{1.2.*}` that should transform something like `org.apache.commons.test.Foo` to `o.a.c.test.Foo`, but I'm seeing it transform into `o.ap.commons.test.Foo` instead.

In general, the configuration I want here is to collapse all the parts of the package name to single letters except for the last package name part before the class name which is what that example precision looks to do.

## Configuration

**Version:** 2.23.1

**Operating system:** macOS

**JDK:** Java 21

## Logs

```
[Stacktraces, errors, etc. relevant applications logs.]
```

## Reproduction

Use `%c{1.2.*}` in a pattern layout with a logger name such as `org.apache.logging.log4j.core.config.AbstractConfiguration` which should output `o.a.l.l.c.config.AbstractConfiguration`. Sample config snippet:

```xml


${sys:app-logging-level:-info}






```

Example output:

```
[File: c.fo.bar.bazzzle.AResourceLogger:52 ]
```

Expected output:

```
[File: c.f.b.bazzzle.AResourceLogger:52 ]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.