Vivek Agarwal’s Portal/Java Blog

An IBM Gold Consultant’s weblog about IBM, Lotus, WebSphere, J2EE, IT Processes, and other IT technologies

Archive for the ‘log4j’ Category

Missing log4j log files with DailyRollingFileAppender when they should roll over?

Posted by Vivek Agarwal on February 9, 2008

Yes, I am back with a blog entry after quite a gap here! I have been knocked out sick for 5 weeks now and I am sick of being sick! Better now and hoping to be back at a 100% soon. Enough excuses – onto the subject of this blog entry. We use Log4j’s DailyRollingFileAppender in a WebSphere Portal environment to generate daily log files for various custom portlets that we have deployed. This worked just fine on some WPE v6 test servers with multiple portlets logging to the same log file, and the daily rollover occurring every midnight. However, on some other WPE v6 test servers running the exact same applications, while logging did work the daily rollover did not. Instead of us having multiple log files with date timestamps in their names, we would only have today’s log file – the previous log files would simply disappear! This issue results from the fact that the DailyRollingFileAppender (DRFA) tries to rename the log file during rollover. However, when the rename fails, it ends up overwriting the log file, hence losing information. On checking the application server’s SystemErr.log, we found an error each midnight similar to –

log4j:ERROR Failed to rename [logfilename] to logfilename.2008.01.11].

This appears to be a fairly common issue with log4j 1.2.x in Java application servers running on Windows. While there is no good resolution for this issue there is a workaround that works pretty well. Read the rest of this entry »

Posted in Java, log4j, WebSphere, WebSpherePortal | 18 Comments »