Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3346

After 2.17.0 upgarde Route appenders with dynamic file writing are not working

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.17.0
    • None
    • Appenders
    • None

    Description

      We switched from the version 2.11.1 to 2.17.0 and writing to separate files stopped working. Configuration log4j:

      <Appenders>
      ...
      <Routing name="routing">
                  <Routes pattern="$${ctx:V_PID}">
                      <Route>
                          <RollingFile name="rolling-${ctx:V_PID}" fileName="${logPath}/task-${ctx:V_PID}.log"
                                                   filePattern="${logArchPath}/task-${ctx:V_PID}-${archFile}" ignoreExceptions="false">
                              <PatternLayout pattern="${pattern}"/>
                              <SizeBasedTriggeringPolicy size="10 MB"/>
                          </RollingFile>
                      </Route>
                  </Routes>
                  <IdlePurgePolicy timeToLive="2" timeUnit="minutes"/>
      </Routing>
      ...
      </Appenders>
      
      <Loggers>
          <Logger name="com.rou.let" level="trace">
                  <AppenderRef ref="routing"/>
          </Logger>
      </Loggers>

       In code we use Slf4J logger (org.slf4j.Logger) and org.apache.logging.log4j.ThreadContext :

      ThreadContext.put("V_PID", pid); 
      org.slf4j.Logger logger =org.slf4j.LoggerFactory.getLogger(MessageFormat.format(...));
      

       maven dependencies in pom.xml: 

      ....
      <slf4j.version>1.7.7</slf4j.version> 
      <log4j2.version>2.17.0</log4j2.version>
      ...
      <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      </dependency>
      
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j2.version}</version>
      </dependency>
      
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>${log4j2.version}</version>
      </dependency>
      
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>${log4j2.version}</version>
      </dependency>
      ...
      

      We use this in our web application which is deployed on Weblogic 12.2.1.0.0

      What can be wrong? Why aren't separate files (task-${ctx:V_PID}.log) created in the folder {logPath}? 

      Before library version 2.12.2 (inclusive),it's worked!

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              nikolaykom Nick Kom
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: