mercredi 5 novembre 2014

How to make log4j2 create a different log file each time I restart jvm


Vote count:

0




I want to create a different log file each time when I run the java application. I have the following configuration. I expected it would create a log file named rf-yyyyMMdd-HHmmss.log which the yyyyMMdd-HHmmss is the time I start the java application. However it doesn't work. Any help would be appreciated!



1 <?xml version="1.0" encoding="UTF-8"?>
2 <configuration status="DEBUG">
3 <appenders>
4 <Console name="Console" target="SYSTEM_OUT">
5 <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
6 </Console>
7 <RollingFile name="RF" filename="/home/sxd/rfjq/rf.log" immediateFlush="false" append="false" filePattern="/home/sxd/r\
fjq/rf-%d{yyyyMMdd-HHmmss}.log">
8 <PatternLayout pattern="[%p] %m%n"/>
9 <Policies>
10 <OnStartupTriggeringPolicy />
11 </Policies>
12 </RollingFile>
13 </appenders>
14 <loggers>
15 <Logger name="model.ModelRF" level="trace">
16 <appender-ref ref="RF"/>
17 </Logger>
18 <root level="trace">
19 <appender-ref ref="Console"/>
20 </root>
21 </loggers>
22 </configuration>


asked 1 min ago

Eastsun

9,468






How to make log4j2 create a different log file each time I restart jvm

Aucun commentaire:

Enregistrer un commentaire