[
https://issues.apache.org/jira/browse/LOG4J2-3317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17477800#comment-17477800
]
Nikolay Komarov commented on LOG4J2-3317:
-----------------------------------------
We switched from the version 2.11.1 to 2.17.0 and writing to separate files
stopped working. Configuration log4j:
{code:xml}
<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>{code}
In code we use Slf4J logger (org.slf4j.Logger) and
org.apache.logging.log4j.ThreadContext :
{code:java}
ThreadContext.put("V_PID", pid);
org.slf4j.Logger logger
=org.slf4j.LoggerFactory.getLogger.getLogger(MessageFormat.format(...));
{code}
maven dependencies in pom.xml:
{code: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>
...
{code}
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!
> After 2.17.1 upgarde, Route appenders with dynamic file writing are not
> working .
> ----------------------------------------------------------------------------------
>
> Key: LOG4J2-3317
> URL: https://issues.apache.org/jira/browse/LOG4J2-3317
> Project: Log4j 2
> Issue Type: Bug
> Environment: spring boot log4j2.
> deployed on wildfly server.
> Reporter: Srinivasa Babu
> Priority: Major
>
> Hello Sir,
> With log4j2 2.13.3 , Route appenders with context pattern checks for dynamic
> file writing are working fine. After 2.17.1 the functionality is broken.
> I have upgraded to 2.17.1 and our java code, I am setting the ROUTINGKEY in
> threadcontext map. Also i set the system properties,
> log4j2.enableJndiLookup, log4j2.enableJndiJms, and
> log4j2.enableJndiContextSelector to true for all said tags after 2.17.1
> upgrade.
> When I check output file, its not writing the logs to Route File what we
> specify but general RollingFile logger appenders are working fine. Please let
> me know if you have faced this issue or any mitigation plan? Please let me
> know if you want any logs and i will share those if there is any specific
> procedure given.
>
> Calling the below Route from Async logging.
> here my example xml used the same as given in log4j2 documentaion.
> <Route key="$${ctx:ROUTINGKEY}">
> <RollingFile name="Rolling-default" fileName="logs/default.log"
> filePattern="./logs/${date:yyyy-MM}/default-%d\{yyyy-MM-dd}-%i.log.gz">
> <PatternLayout>
> <pattern>%d\{ISO8601} [%t] %p %c\{3} - %m%n</pattern>
> </PatternLayout>
> <Policies>
> <TimeBasedTriggeringPolicy interval="6" modulate="true" />
> <SizeBasedTriggeringPolicy size="10 MB" />
> </Policies>
> </RollingFile>
> </Route>
> <Route>
> <RollingFile name="Rolling-${ctx:ROUTINGKEY}"
> fileName="logs/other-${ctx:ROUTINGKEY}.log"
> filePattern="./logs/${date:yyyy-MM}/${ctx:ROUTINGKEY}{-}other{-}%d\{yyyy-MM-dd}-%i.log.gz">
> <PatternLayout>
> <pattern>%d\{ISO8601} [%t] %p %c\{3} - %m%n</pattern>
> </PatternLayout>
> <Policies>
> <TimeBasedTriggeringPolicy interval="6" modulate="true" />
> <SizeBasedTriggeringPolicy size="10 MB" />
> </Policies>
> </RollingFile>
> </Route>
> </Routes>
> </Routing>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)