1 year ago
#388473
Julius
Zip a Log4j-file from another date on startup
I know that with log4j the user has the possibility to compress a file at rollover. But is there a possibility to stop my application, start it again on the next day and still compress the file, that has been created yesterday and therefore contains yesterdays date ? Due to the difference in the Filenames, because of the new Date, the old file is not compressed. Is there a solution besides creating a cronjob or similar to zip my logfile from the last day ?
<Appenders>
<RollingFile name="RollingFile" fileName="${log-path}/server.log.${date:yyyyMMdd}" filePattern="${log-path}/server.log.%d{yyyyMMdd}.%i.zip">
<PatternLayout>
<pattern>%d{ISO8601} %-5p [%-16t] %-25c{1} %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="MonitoringLogger" level="INFO">
<AppenderRef ref="RollingFile"/>
</Logger>
<Root level="INFO" additivity="false">
<AppenderRef ref="RollingFile"/>
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
logging
log4j
log4j2
0 Answers
Your Answer