Skip to content

Log4J pattern layout inconsistencies when locale is specified #4129

@xzel23

Description

@xzel23

Description

Log4J pattern layout supports a timezone argument and an (undicumented?) locale argument.

These patterns both work as expected, i.e., in the second example the german month names are used even when the system uses an english locale:

  •        "%d{dd-MMMM-yyyy}{GMT} %p %m%n",
    
  •        "%d{dd-MMMM-yyyy}{GMT}{de-DE} %p %m%n"
    

That looks like the timezone argument were optional, but then this should also work, but does not:

  •         "%d{dd-MMMM-yyyy}{de-DE} %p %m%n",
    
  •         "%d{EEEE, dd. MMMM yyyy}{de-DE} %p %m%n",
    

In these two latter cases, the locale argument is silently ignored, i.e., when run on a system with an English locale, english month names are used.

I think it should either work (use the month names according to the locale specified) or be documented.

Configuration

Version: 2.26.0

Operating system: MacOS 26.5

JDK: 17

Reproduction

The original test is part of a rather large test suite for my Log4J compatible pattern parser. I can put some time into creating a JUnit test, but I'd like to know what you guys think of it as it's not clear if this is intended the way it works now (then documentation should be updated) or not (then I'd make it a real JUnit test). I had Codex create a minimal example just to give you an idea.

Log4jLocaleTest.java

Metadata

Metadata

Labels

apiAffects the public APIbugIncorrect, unexpected, or unintended behavior of existing codelayoutsAffects one or more Layout plugins

Type

No type
No fields configured for issues without a type.

Projects

Status

To triage

Relationships

None yet

Development

No branches or pull requests

Issue actions