Why can't create newly log file including daily date by using DailyRollingFileAppender?

StackOverflow https://stackoverflow.com/questions/23213694

  •  07-07-2023
  •  | 
  •  

문제

I'm trying to configure log4j framework by using appender, "DailyRollingFileAppender" and want to create newly log file including daily date like {log.txt.2014-04-22", but it failed.

Here is my log4j.properties.

logPath=c:\\
logFilename=log.txt

log4j.rootLogger=DEBUG, FILE

log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=${logPath}${logFilename}
log4j.appender.FILE.ImmediateFlush=true 
log4j.appender.FILE.Append=true
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} | %p | %C | %M:%L | %m%n%n

Although I succeed to make a test through junit, the log file was not created like "log.txt.2014-04-22". It was created as "log.txt"

What am I missing ? please give me an advice. Thanks a lot.

도움이 되었습니까?

해결책

The file created today will not have date appended. If you change the system date and run the application then the new file with log.txt will be created and old file will be appended with date.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top