java - Time discrepancy between data in logfiles and timestamp in corresponding filenames -


i switched log4j using property file, using xml , log4j2, because wanted timestamps on log files.

    <rollingfile name="file" filename="log/${name}.log"         filepattern="log/${name}-%d{dd-mm-yyyy_hh.mm.ss}.log">         <patternlayout             pattern="${pattern}" />          <policies>             <onstartuptriggeringpolicy>false</onstartuptriggeringpolicy>             <sizebasedtriggeringpolicy size="100 mb" /> <!-- or every 100 mb -->         </policies>      </rollingfile> 

my problem timestamps on files 'new' content, because of logging mechanics, i. e. after each run of program file ${name}.log written, if there file given name, file log/${name}-%d{dd-mm-yyyy_hh.mm.ss}.log created , content of former file copied it. ${name}.log overwritten logging information of current run.

so there discrepancy between content of timestamped log files , time given in name.

question

is possible fix issue? , if is, have configure?


example

name.log : contains data second run

19-07-2013 13:10:58.462 [main] info  main.app (app.java:60)  trying print string!  19-07-2013 13:10:58.467 [main] info  main.app (app.java:61)  aware!  19-07-2013 13:10:58.467 [main] info  main.app (app.java:63)  string printed  19-07-2013 13:10:58.467 [main] debug main.app (app.java:64)  program executed! 

name-19-07-2013_13.10.58.log : contains data first run

19-07-2013 13:00:10.788 [main] info  main.app (app.java:60)  trying print string!  19-07-2013 13:00:10.794 [main] info  main.app (app.java:61)  aware!  19-07-2013 13:00:10.795 [main] info  main.app (app.java:63)  string printed  19-07-2013 13:00:10.795 [main] debug main.app (app.java:64)  program executed! 

additional data

run #1 started at: 19-07-2013 13:00:10 run #2 started at: 19-07-2013 13:10:58  run #1 log file  : name-19-07-2013_13.10.58.log run #2 log file  : name.log 

as can see, file name of first run's log depends on when second run started. find irritating , misleading.

it's not possible configure of existing appenders want.

you use fileappender doesn't roll on when gets big.

the rollingfileappender write filename , move content of file 1 supplied pattern after conditions met (so never create file specified pattern , write it). means, point of view, timestamp of file after last log entry in file. design.

to fix issue, have write own appender.


Comments