Closed class101 closed 8 months ago
I can't upload files so here is my log4j2.xml, running any test with it under v2.21.0 or greater and another one to any version up to 2.20.0 should suffice to notice the behavior
<?xml version="1.0" encoding="UTF-8"?>
<!-- Les mises a jour de ce fichier sont prises en compte sans redemarrage du serveur toutes les 10 secondes -->
<Configuration status="INFO" monitorInterval="10">
<Properties>
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xEx</Property>
<!-- Masque le stacktrace si actif -->
<Property name="LOG_NO_EXCEPTION">%ex{0}</Property>
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
<Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
<Property name="COLOR_START">%highlight{</Property>
<!-- Les couleurs par defaut -->
<Property name="COLOR_END">}{FATAL=Bright red, ERROR=Bright red, WARN=Yellow, INFO=Normal, DEBUG=White, TRACE=Blue}</Property>
<!-- Mets en évidence le niveau DEBUG en utilisant la meme couleur que INFO si actif -->
<Property name="COLOR_END_DEBUG_AS_INFO">}{FATAL=Bright red, ERROR=Bright red, WARN=Yellow, INFO=Normal, DEBUG=Normal, TRACE=Blue}</Property>
<!--
Les identifications de l'utilisateur, voici les codes disponibles :
(Il est possible d'jouter ce que l'on veut, voir cl-core-service/LogFilter.java pour le détail)
- sessionId -> 771E87A24A5B03D2B4795B1DFAFDC600
- userId -> 06130036
- browserDetails -> Chrome - 116.0.0.0
- codeEmploye -> admin
- codeSigle -> CL
- codeBanque -> 19230
- codeGuichet -> 00001
- codeOrganisme -> 09750036
-->
<Property name="USER_ID">%notEmpty{[%notEmpty{%X{codeEmploye}-}%notEmpty{%X{userId}-}%notEmpty{%X{sessionId}}] }</Property>
<Property name="CONSOLE_LOG_PATTERN">${sys:COLOR_START}%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid - [%15.15t] %-40.40c{1.} : ${sys:USER_ID}%m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}${sys:COLOR_END}</Property>
<Property name="CONSOLE_LOG_PATTERN_DEBUG_COLOR_AS_INFO">${sys:COLOR_START}%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid - [%15.15t] %-40.40c{1.} : ${sys:USER_ID}%m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}${sys:COLOR_END_DEBUG_AS_INFO}</Property>
<Property name="CONSOLE_LOG_PATTERN_NO_EXCEPTION">${sys:COLOR_START}%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid - [%15.15t] %-40.40c{1.} : ${sys:USER_ID}%m%n${sys:LOG_NO_EXCEPTION}${sys:COLOR_END}</Property>
<Property name="CONSOLE_LOG_PATTERN_NO_EXCEPTION_DEBUG_COLOR_AS_INFO">${sys:COLOR_START}%d{${sys:LOG_DATEFORMAT_PATTERN}} ${sys:LOG_LEVEL_PATTERN} %pid - [%15.15t] %-40.40c{1.} : ${sys:USER_ID}%m%n${sys:LOG_NO_EXCEPTION}${sys:COLOR_END_DEBUG_AS_INFO}</Property>
</Properties>
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT" follow="true">
<PatternLayout disableAnsi="${sys:crelog.log4j.color.disabled:-true}" pattern="${sys:CONSOLE_LOG_PATTERN}" />
</Console>
<Console name="CONSOLE_NO_EXCEPTION" target="SYSTEM_OUT" follow="true">
<PatternLayout disableAnsi="${sys:crelog.log4j.color.disabled:-true}" pattern="${sys:CONSOLE_LOG_PATTERN_NO_EXCEPTION}" />
</Console>
<Console name="CONSOLE_NO_EXCEPTION_DEBUG_COLOR_AS_INFO" target="SYSTEM_OUT" follow="true">
<PatternLayout disableAnsi="${sys:crelog.log4j.color.disabled:-true}" pattern="${sys:CONSOLE_LOG_PATTERN_NO_EXCEPTION_DEBUG_COLOR_AS_INFO}" />
</Console>
</Appenders>
<Loggers>
<!--
Crédit Logement
-->
<Logger name="fr.cl" level="DEBUG" />
<Logger name="commun" level="DEBUG" />
<Logger name="com.crelog" level="DEBUG" />
<Logger name="centricite" level="DEBUG" />
<Logger name="wscl.framework" level="DEBUG" />
<!--
SQL Queries par Hibernate :
Si besoin de voir les requetes SQL et leurs parametres :
org.hibernate.SQL=DEBUG
org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-->
<Logger name="org.hibernate.SQL" level="${sys:crelog.log4j.sql:-DEBUG}" />
<Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="${sys:crelog.log4j.sql:-TRACE}" />
<!--
MQ managé par le starter Spring Boot d'IBM
-->
<Logger name="com.ibm.mq.spring.boot" level="TRACE" />
<Root level="INFO">
<AppenderRef ref="CONSOLE"/>
</Root>
</Loggers>
</Configuration>
@class101, thanks for reaching out to us! This issue has already been reported in #1922 and fixed, which will be shipped in the upcoming 2.22.0
release. I intend to perform the release at the end of this week.
I would appreciate it if you can inform us on whether you can reproduce the issue with 2.22.0-SNAPSHOT
or not.
@vy I confirm 2.22.0-SNAPSHOT
fixes the problem, it is back to the original behavior.
Thanks a lot for the fast reply and sorry for the duplicate 👍
Description
The following fix LOG4J2-3660 is changing the behavior of
%notEmpty
and I'm wondering if this is intended or not, or if I'm using it the correct way to achieve the following behaviorUp to 2.20.0, I'm using the following template which is working perfectly :
The following expected results are generated:
But after upgrading to 2.21.0+
[--]
is printedThis happens before entering into my LoggingFilter, before touching the MDC map, straight from the Spring Boot application Startup
Configuration
Version: [Log4j version]
Operating system: [OS and version]
JDK: [JDK distribution and version]
Logs
The following is a 2.20.0 startup Log working as intended showing "[admin-47D3117E24FD612CD8D6231549606BA5]"
The following is a 2.21.0 startup Log not working as intended showing [--] straight from Spring Boot startup and it is showing an extra - between admin and the sessionId
Reproduction
I'm attaching log4j2.xml and LogFilter.java
Edit: My organization is blocking my files, let me know if they are necessary I will upload somewhere else
(To note that the issue is shown before reaching LogFilter.java)
[An isolated test reproducing the test. JUnit tests similar to the ones in the code base are extremely appreciated.]