[
https://issues.apache.org/jira/browse/LOG4J2-3180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433566#comment-17433566
]
Ralph Goers commented on LOG4J2-3180:
-------------------------------------
I am not sure what you are expecting. The fileName attribute is only evaluated
when the configuration is processed so ${ctx:param} will have whatever value
was in the ThreadContext before the configuration is created. It is highly
unusual to use a ThreadContext value in the fileName or filePattern attributes
since the fileName is only evaluated when the configuration is created and
since the filePattern is only evaluated during a rollover, which with the
SizeBasedTriggeringPolicy can happen on any thread. It isn't clear what
"counter" you are refering to as there is no %i in the filePattern in your
example configuration.
> AbstractRolloverStrategy:getEligibleFiles(): The file name cannot match
> normally when it has special characters of regular expression (such as: [] {})
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3180
> URL: https://issues.apache.org/jira/browse/LOG4J2-3180
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders, Core
> Affects Versions: 2.14.1
> Reporter: Shun
> Priority: Minor
>
>
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="ERROR">
> <Appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level
> %logger{36} - %msg%n"/>
> </Console>
> <Routing name="Routing">
> <Routes pattern="$${ctx:param}">
> <Route>
> <RollingFile name="Rolling"
> fileName="./log/${ctx:param}.log"
> filePattern="./log/${ctx:param}.log">
> <PatternLayout>
> <pattern>%d %p %c{1.} [%t] %m%n</pattern>
> </PatternLayout>
> <SizeBasedTriggeringPolicy size="1KB" />
> </RollingFile>
> </Route>
> </Routes>
> <!--<IdlePurgePolicy timeToLive="15" timeUnit="minutes"/>-->
> </Routing>
> </Appenders>
> <Loggers>
> <Root level="ALL">
> <AppenderRef ref="Console"/>
> <AppenderRef ref="Routing"/>
> </Root>
> </Loggers>
> </Configuration>{code}
>
> filePattern="./log/${ctx:param}_%i.log" The counter will never increase
> when the "param" is set like
> ThreadContext.put("param", "{color:#ff0000}[{color}Just For
> Test{color:#ff0000}]{color}");".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)