Differences between revisions 4 and 5
Revision 4 as of 2006-08-27 11:45:42
Size: 3555
Comment: Moved Using Log4J in James to new page
Revision 5 as of 2009-09-20 22:58:40
Size: 3549
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 65: Line 65:
see also [http://avalon.apache.org/api/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.html FileTargetFactory] see also [[http://avalon.apache.org/api/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.html|FileTargetFactory]]
Line 79: Line 79:
[wiki:Self:log4j Using Log4J in James] [[log4j|Using Log4J in James]]

Log Rotation for Apache James

James uses the Avalon logging mechanism. In some ways, this is a mini-tutorial on Avalon log rotation.

Each of these situations is addressable by customizing Jame's logging configuration in SAR-INF/environment.xml. Each log file is independently configurable. Right now each of the log files is configured identically in the default configuration, but there may be log files that rarely change, and don't need to be rotated on the same schedule as others.

We cannot guess what custom configuration everyone will want in their logs. We have to pick a default pattern and policy set, and stick with it. If James users indicate some sort of broad agreement on how they typically want logs rotated, we can make that the default.

Anyone who wants to can reconfigure the log rotation. Most administrators rotate logs, if they rotate them, on a periodic basis. The way Avalon rotates using a date, logs can rotate hourly, daily, monthly, or yearly. They could rotate at specific points during the day with a <time> element, or when a size is reached with a <size> element.

For example, the current:

     <rotation type="unique" pattern="-yyyy-MM-dd" suffix=".log">

rotates that log daily. Adding


would rotate at a 100MB boundary, within the day.

However, because of the way Avalon's UniqueFileStrategy class constructs the filename, simply adding another rotation policy won't work properly if rotation can occur more often than daily. The pattern attribute is only set for daily rotation. We'd need to change the pattern to be something like "-yyyy-MM-dd-HH" to allow rotation (for whatever reason) hourly, or "-yyyy-MM-dd-HH-mm" if the log could rotate more than once within an hour. So instead of having a file name like:


we'd have to have:

   smtpserver-2003-01-26-18.log or smtpserver-2003-01-26-18-30.log 

if we expect to rotate more than daily. That might look something like:

     <rotation type="unique" pattern="-yyyy-MM-dd-HH-mm" suffix=".log">

To set up logs to be prefixed with the date, such as 20030215-smtpserver.log, the following definition can be used -

         <file id="James-target">
           <format>%{time:dd/MM/yy HH:mm:ss} %5.5{priority}%{category}: %{message}\n%{throwable}</format>
           <rotation type="unique" pattern="yyMMdd" <B>suffix="smtpserver.log"</B>>

Note the way the filename element is used and how the descriptive name is set with the suffix attribute. The same rules governing <I>hourly</I> rotation as described above still apply; this is just another way to represent the log file names.

see also FileTargetFactory

Here is some more information about configuration of the logging: http://rzserv2.fhnon.de/~lg002556/james/James.html#d3e143

Log Rotation for Apache James using Log4J

see also Using Log4J in James

LogRotation (last edited 2009-09-20 22:58:40 by localhost)