I want to change my filename in my rollingfile appender and add current date to it here is my config :
<RollingFile
name="rollingFile"
fileName="logs/%d{YYYY-MM-DD}.application.log"
filePattern="logs/application.%d{dd-MMM}.log.gz"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%m</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
but when I do this the file that is created for me in my logs folder is Like this :
%d{YYYY-MM-DD}.application.log
why? I just want to add my current date but log4j doesn't detect %d{YYYY-MM-DD} pattern and adds the exact string??!
As far as I understand fileName
should be the exact name of the log file before it is "rolled" (the active log file). The filePattern
determines what the file is renamed to when it is rolled. Try setting fileName
to just logs/application.log
and use the date format you want for archived files in filePattern
.