Sunday 30 August 2009

Daily Rollover Issue Fixed in TimeAndSizeRollingAppender

Thanks to Bernd who reported a bug in handling of the DatePattern parameter. In
one place in the code the parameter was being parsed as if it contained localized pattern characters, but in another localization was being ignored. My bad for having tested only with ENGLISH locales. The code is fixed and, based upon the principle of least surprise, the appender now always defaults to the ENGLISH locale, as per the Javadoc on SimpleDateFormat. To set up any locale other than ENGLISH, simple use the DatePatternLocale parameter with the language and/or country code as described in the appender Javadoc (e.g. "fr_CA", "de", etc). New code at http://www.simonsite.org.uk.

6 comments:

Manjit said...

I see one strange issue with the "MaxFileSize" property (value="5KB"). I just configured the TimeAndSizeRollingAppender just to check if the rolling and backup are fine with in my JBoss log4j.xml.

It created the backup files with the specified "DatePattern". But strangely, backup files were created exceeding the max file size. Also, the log messages kept appending in the backed-up file. Am I missing anything in my configuration or is there any minimum value limit for "MaxFileSize" property?

Thanks

Simon said...

Manjit, 5KB is an extremely small size for a log file! By how much are the backups exceeding the 5KB limit? I wouldn't be too surprised to hear that it's only by some fraction of the bytes that make up the last line in the backup file. However, I'd like to know for sure, so please let me know what you find. Thanks.

Chandra said...

Hi Simon,

Your appenders are very useful and i'm using it.

m i free to use your appenders? :D thanks

Anonymous said...

whats the license of this

Simon said...

Apache 2.0 license. Feel free to use the software, but let me know about any changes you make!

ives said...

Very useful indeed. Thanks a lot for sharing this! This should be part of the basic log4j distribution.