File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Log4J DailyRollingFileAppender not rolling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4J DailyRollingFileAppender not rolling" Watch "Log4J DailyRollingFileAppender not rolling" New topic
Author

Log4J DailyRollingFileAppender not rolling

Gezza Hall
Ranch Hand

Joined: Jan 04, 2005
Posts: 33
Hi, I have a Logging utility class which wraps the log4j API and allows simple logging. It programmatically sets a DailyRollingFileAppender, and it's always worked without a hitch for me.

Now, I'm integrating into an existing tomcat webapp. Using my class, the log files are not rolling, but just continue to build up in the same file. I have noticed a properties file in the WEB-INF directory called log.properties, which contains the usual Log4j configuration. This file specifies a RollingFileAppender set to roll at 10Mb. Is there a chance that my class, when run under tomcat, is picking up this config file by default?

If so, can I stop it doing that?
If not, what else could be causing my log files not to roll?

Many thanks for any help!
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Gezza Hall:
If so, can I stop it doing that?

Why do not you configure the logging system using PropertyConfigurator Class and specify the configuration file.


Rahul Bhattacharjee
LinkedIn - Blog
Gezza Hall
Ranch Hand

Joined: Jan 04, 2005
Posts: 33
I probably 'could' but want to keep it simple in this case.

Besides, I don't think that the existing log.properties file is the problem here - for some reason my logs simply aren't rolling!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Originally posted by Gezza Hall:
Is there a chance that my class, when run under tomcat, is picking up this config file by default?
Seems to me there are several simple experiments you could do to find that out. Such as changing that config file and see if what you changed made a difference.
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Some buddy once told me that the DailyRollingFileAppender will only roll if Log4j is active at midnight, so the server has to be running constantly. I never checked that, but you might test that as well by resetting your local computer time (if it's possible to test your application locally).
Gezza Hall
Ranch Hand

Joined: Jan 04, 2005
Posts: 33
Yeah I've done the experiments, and it's not a conflict with the other files.

Strangely, the rolling logs work on my local machine, which is not active at midnight - but they don't work on our tomcat machine which is permanently running.
 
GeeCON Prague 2014
 
subject: Log4J DailyRollingFileAppender not rolling