Tuesday, 18 May 2010
Roll Log4J log files on application startup
Sunday, 30 August 2009
Daily Rollover Issue Fixed in TimeAndSizeRollingAppender
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.
Sunday, 26 April 2009
Log4J Log Rolls At Midnight
It seems to me that it would be convenient if the appender could take care of rolling files on a schedule itself, so I've added this behaviour to the Log4J TimeAndSizeRollingAppender hosted on my site at www.simonsite.org.uk.
The new stuff doesn't try to be too clever. It simply looks at the DatePattern config parameter of the appender (this is in common with the DailyRollingFileAppender) and assumes that the end-point of a logging period implied by it is when rolling should happen. So if you have a DatePattern set to 'yyyy-MM-dd' the appender assumes that it should force a file roll at the end of every day.
Thursday, 5 February 2009
Compression Added
- Backup log files can be compressed.
- The scavenger thread that deletes older files can be configured not to run, thereby conserving resources whilst allowing a virtually unlimited number of backups.
Saturday, 20 December 2008
TimeAndSizeRollingAppender Updated
Monday, 24 March 2008
Log4J Asynchronous Appender Contrib
Tuesday, 23 October 2007
Log4J Asynchronous Appender
In trying to minimise such pauses whilst maximising throughput, I've come up with a slightly different solution to the same problem that AsyncAppender tries to address. The ActiveAsynchronousAppender I have developed blocks when the buffer is full, however it only appends a single LoggingEvent from its buffer at a time, before checking the buffer again. As soon as the buffer is below its maximum size, the appender ceases to block.
I've run the new code against the Log4J 1.2.15 unit tests for the AsyncAppender, and the important tests pass. The caveat is that my code is not designed for "non-blocking" operation, i.e. it cannot be configured to discard LoggingEvents when the appender's buffer is full.
What are the benefits of the new code? As with the standard Log4J AsyncAppender, it depends in no small part upon the nature of the application, and tuning the size of the appender's buffer. I don't yet have any hard figures to demonstrate whether my appender code offers any significant advantage over the existing Log4J AsyncAppender. A couple of things I'm looking at:
- Reduced blocking should lead to higher application throughput
- Fewer LoggingEvents on the stack of a daemon thread may mean more reliable logging at the end of an application lifecycle (not sure about this)