ppkarwasz commented on issue #3930:
URL: 
https://github.com/apache/logging-log4j2/issues/3930#issuecomment-3306639987

   Hi @tanmaybaid, great catch! 🙌
   
   You’ve run into a bug where multi-character **unquoted** literals (e.g., `", 
"`, `" ,"`, or two spaces) are merged incorrectly by the new instant formatter, 
which can inject a stray apostrophe at the boundary (e.g., `Thu,' 18 …`). I’ve 
opened #3932 to fix the parsing/merging logic.
   
   ### Recommended workaround
   
   Quote the literal runs in your pattern. This follows the JDK guidance to 
quote all literal text to avoid surprises:
   
   > “it is recommended to use single quotes around all characters that you 
want to output directly” — [`DateTimeFormatter` 
Javadoc](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/format/DateTimeFormatter.html)
   
   For your examples:
   
   * `%date{EEE, dd MMM yyyy HH:mm:ss zzz}` → `%date{EEE', 'dd MMM yyyy 
HH:mm:ss zzz}`
   * `%date{EEE ,dd MMM yyyy HH:mm:ss zzz}` → `%date{EEE' ,'dd MMM yyyy 
HH:mm:ss zzz}`
   * `%date{EEE  dd MMM yyyy HH:mm:ss zzz}` → `%date{EEE'  'dd MMM yyyy 
HH:mm:ss zzz}`
   
   > [!NOTE]
   > We don’t recommend switching to the legacy formatter. Quoting the literals 
is the safe, forward-compatible workaround, and the underlying bug is being 
addressed in **#3932**. For custom patterns like yours, the new formatter is 
much faster as it caches most of the data between calls.
   
   Thanks again for reporting this!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to