Log4j Not Rolling Files

B

Brett Sheeran

Hi I am using log4j 1.2.8 with Tomcat. I am trying to log errors to daily
files using DailyRollingFileAppender. The current days logs are saved to
file. However, I am finding that the previous days logs are not being saved
to file. I have a copy of my properties file below. Can anyone tell me why
this is happening?

Thanks.

Regards Brett Sheeran


# Set root logger level to DEBUG and its only appender to A1.
log4j.rootCategory=DEBUG, A1, A2

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern= %-5p %c - %m%n

# set appender A2 as file appender
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.File=c:/WebReports/Logs/campbells.log
log4j.appender.A2.DatePattern='.'yyyy-MM-dd
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.A2.MaxFileSize=10MB
 
O

Oscar kind

Brett Sheeran said:
Hi I am using log4j 1.2.8 with Tomcat. I am trying to log errors to daily
files using DailyRollingFileAppender. The current days logs are saved to
file. However, I am finding that the previous days logs are not being saved
to file. I have a copy of my properties file below. Can anyone tell me why
this is happening?

AFAIK, log4j only rolls log files when log4j is active at the rollover
moment. Thus if you have a log file for each day, log4j will only roll if
it is active at midnight. In my experience, log4j works as expected with
continuously running servers.

Of course, this doesn't work if you're testing the server (and thus are
running it only for short times). But in such cases I always remove of
archive the log files, thus removing the problem that way.

Simple programs (that are run again and again) are another matter.
However, in such cases I prefer log files for each run. This has the side
effect of alleviating the problem above.


Oscar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top