[ 
https://issues.apache.org/jira/browse/LOG4J2-907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15327037#comment-15327037
 ] 

K P edited comment on LOG4J2-907 at 6/13/16 9:30 AM:
-----------------------------------------------------

This would be a very welcome (actually needed) addition.

It was possible in Log4j 1.x, see 
http://stackoverflow.com/questions/30059333/log4j2-rolling-appender-filename-sliding-according-to-pattern

Many people are requesting it
* see SO post above, with an ugly hack that unfortunately needs reflection on 
the log4j2 API to get it done
* another SO post, of the above reporter: 
http://stackoverflow.com/questions/27155363/log4j2-change-filename-dynamically-in-rollingfile-appender
* see also LOG4J2-1185
* also LOG4J2-239 and LOG4J2-1027 are the same underlying problem
* ...

As this was fairly easy possible in log4j 1.x, this is something we really miss 
(without hack) in log4j2 for our required log file name structure... 


was (Author: belpk):
This would be a very welcome (actually needed) addition.

It was possible in Log4j 1.x, see 
http://stackoverflow.com/questions/30059333/log4j2-rolling-appender-filename-sliding-according-to-pattern

Many people are requesting it
* see SO post above, with an ugly hack that unfortunately needs reflection on 
the log4j2 API to get it done
* another SO post, of the above reporter: 
http://stackoverflow.com/questions/27155363/log4j2-change-filename-dynamically-in-rollingfile-appender
* see also LOG4J2-1185
* ...

As this was fairly easy possible in log4j 1.x, this is something we really miss 
(without hack) in log4j2 for our required log file name structure... 

> Log4j2 rolling policy
> ---------------------
>
>                 Key: LOG4J2-907
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-907
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.1
>         Environment: windows 7 enterprise
>            Reporter: Clement Caylux
>            Assignee: Ralph Goers
>         Attachments: log4j2.xml
>
>
> I am using log4j2 and a rolling file appender, to roll file based on size and 
> time. See my attached config file config file and the following snippet:
> {code:xml}
>  <RollingFile name="RollingFile" 
> filename="log/$${date:dd-MM-yyyy-HH-mm}/currentRoll.log" 
> filePattern="log/%d{dd-MM-yyyy-HH-mm}/Roll-%i.log">
>             <PatternLayout>
>                 <Pattern>%d{ISO8601}{GMT} %p %c{1.c} [%t] %m%n</Pattern>
>             </PatternLayout>
>             <Policies>
>                 <TimeBasedTriggeringPolicy interval="1"/>
>                 <SizeBasedTriggeringPolicy size="3KB"/>
>             </Policies>
>         </RollingFile>
> {code}
> My problem is that my current log (currentRoll.log) file is in the folder 
> that was first created when the program started. I would need it to be in the 
> last. So for example if I start running the program at 1pm on November 25th, 
> 2014 , and at 3pm I want to look at the current logs they would not be in the 
> 25-11-2014-15 folder but in the 25-11-2014-13 folder.
> My guess is that the date in the filename is not resolved dynamically. I have 
> tried using monitorInterval to poll for auto reconfiguration but did not have 
> any luck. I also tried using a '$$' in   
> {code:xml}
> filename="log/$${date:dd-MM-yyyy-HH-mm}/currentRoll.log" .
> {code}
>  but got the following error:
> {code}
> ERROR Unable to create file log/${date:dd-MM-yyyy-HH-mm}/currentRoll.log 
> java.io.IOException: The filename, directory name, or volume label syntax is 
> incorrect
> {code}
> Any suggestion?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to