<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Vivek Agarwal's Portal/Java Blog &#187; log4j</title>
	<atom:link href="http://vivekagarwal.wordpress.com/category/log4j/feed/" rel="self" type="application/rss+xml" />
	<link>http://vivekagarwal.wordpress.com</link>
	<description>An IBM Gold Consultant's weblog about IBM, Lotus, WebSphere, J2EE, IT Processes, and other IT technologies</description>
	<lastBuildDate>Tue, 27 Oct 2009 03:15:20 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='vivekagarwal.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/da8f819b3926c7922045a2bb8dda8053?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Vivek Agarwal's Portal/Java Blog &#187; log4j</title>
		<link>http://vivekagarwal.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vivekagarwal.wordpress.com/osd.xml" title="Vivek Agarwal&#8217;s Portal/Java Blog" />
		<item>
		<title>Missing log4j log files with DailyRollingFileAppender when they should roll over?</title>
		<link>http://vivekagarwal.wordpress.com/2008/02/09/missing-log4j-log-files-with-dailyrollingfileappender-when-they-should-roll-over/</link>
		<comments>http://vivekagarwal.wordpress.com/2008/02/09/missing-log4j-log-files-with-dailyrollingfileappender-when-they-should-roll-over/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 00:50:45 +0000</pubDate>
		<dc:creator>Vivek Agarwal</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[WebSphere]]></category>
		<category><![CDATA[WebSpherePortal]]></category>
		<category><![CDATA[log4j]]></category>

		<guid isPermaLink="false">http://vivekagarwal.wordpress.com/?p=94</guid>
		<description><![CDATA[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 &#8211; onto the subject of this blog entry. We use Log4j&#8217;s DailyRollingFileAppender [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vivekagarwal.wordpress.com&blog=929801&post=94&subd=vivekagarwal&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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 &#8211; onto the subject of this blog entry. We use Log4j&#8217;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 <i>today&#8217;s</i> log file &#8211; 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&#8217;s SystemErr.log, we found an error each midnight similar to -</p>
<p>log4j:ERROR Failed to rename [logfilename] to logfilename.2008.01.11].</p>
<p>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.  <span id="more-94"></span></p>
<p>We ended up getting the DatedFileAppender which is a log4j extension that is publicly available at <a href="http://minaret.biz/tips/datedFileAppender.html" target="_blank">http://minaret.biz/tips/datedFileAppender.html</a>. DatedFileAppender avoids the need for renaming the log file by simply creating the log file initially with the date in the file name &#8211; this is a simple workaround for the problem that we were experiencing. Switching from the DailyRollingFileAppender to DatedFileAppender was fairly seamless.  In addition to installing the jar in WebSphere Portal, we had to switch a few lines of our log4j configuration. We changed the following lines -</p>
<p>log4j.appender.logFileAppender=org.apache.log4j.DailyRollingFileAppender<br />
log4j.appender.logFileAppender.DatePattern=&#8217;.'yyyy-MM-dd<br />
log4j.appender.logFileAppender.File=MyApps.log</p>
<p>to</p>
<p>log4j.appender.logFileAppender=biz.minaret.log4j.DatedFileAppender<br />
log4j.appender.logFileAppender.Directory=.<br />
log4j.appender.logFileAppender.Prefix=MyApps_<br />
log4j.appender.logFileAppender.Suffix=.log<br />
log4j.appender.sametimeSyncAppender.Period=month # this line is only needed if the period is not a day</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vivekagarwal.wordpress.com/94/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vivekagarwal.wordpress.com/94/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vivekagarwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vivekagarwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vivekagarwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vivekagarwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vivekagarwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vivekagarwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vivekagarwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vivekagarwal.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vivekagarwal.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vivekagarwal.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vivekagarwal.wordpress.com&blog=929801&post=94&subd=vivekagarwal&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vivekagarwal.wordpress.com/2008/02/09/missing-log4j-log-files-with-dailyrollingfileappender-when-they-should-roll-over/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51b07703056eac6cc06db437b8cfe663?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Vivek</media:title>
		</media:content>
	</item>
	</channel>
</rss>