A LogEvent sink is a LogListener that performs a final action on a LogEvent. This may include writing the LogEvent to a file, sending the LogEvent as e-mail, or writing the LogEvent to a database. Dynamo defines several different kinds of LogEvent sinks:

PrintStreamLogger

A PrintStreamLogger writes logging messages to a PrintStream. By default, a PrintStreamLogger is configured to write logging messages to System.out, which usually leads to the console.

A PrintStreamLogger is useful as a debugging tool during development. Dynamo defines a PrintStreamLogger called /atg/dynamo/service/logging/ScreenLog of the atg.nucleus.logging.PrintStreamLogger class. By default, the ScreenLog component is a logListener for all Nucleus components that implement ApplicationLogging. You can disable the ScreenLog component by setting its loggingEnabled property to false. This is the recommended setting for live Dynamo sites.

FileLogger

A FileLogger writes logging messages to a text file. There are two properties that define an instance of a FileLogger:

You can disable any FileLogger component by setting its loggingEnabled property to false.

RotatingFileLogger

A RotatingFileLogger is a subclass of atg.nucleus.logging.FileLogger that periodically archives its log file to another directory. This prevents log files from growing without bound, but still allows you to keep some log file history around.

The archiving is controlled by the following properties:

schedule
The Schedule to use to perform the archiving (see
Configuring a Schedulable Component). This is often set to a CalendarSchedule, allowing it to perform the archiving on a calendar-based schedule such as “every Sunday morning at 1am.”

logArchivePath
The directory into which the archived log files are to be placed. This is usually different from the logFilePath, to make it easier for you to manage your log files and your archive files separately.

maximumArchiveCount
This is the maximum number of archive files that are kept for a particular log file. Once this maximum has been reached, the oldest file is discarded whenever the log file is archived.

archiveCompressed
Specifies whether log files are compressed before being archived. See below.

When the log file is archived, it is moved from the logFilePath to the logArchivePath, and is renamed <logFileName>.0. If there already is a <logFileName>.0, it is renamed <logFileName>.1. 1 is renamed to 2, 2 is renamed to 3, etc. This rotation stops at the maximumArchiveCount. If the maximumArchiveCount is 10, then <logFileName>.9 is not moved to <logFileName>.10, but is instead erased.

After the log file is archived, a new log file is opened in the logFilePath, and logging continues as normal.

You also have the option of compressing log files before they are archived. If the archiveCompressed property is set to true, then log files will be compressed into a ZIP file format. The archived log files will also have the extension .zip. These compressed log files can be read by a standard ZIP file reader, or by using the jar command that comes with the JSDK:

jar xvf info.log.0.zip

One example instance of RotatingFileLogger can be found at /atg/dynamo/service/logging/InfoLog. It has the following properties:

$class=atg.nucleus.logging.RotatingFileLogger
logFilePath=./logs
logFileName=info.log
logListeners=ErrorLog

scheduler=../Scheduler
schedule=calendar * . 1 1 0
logArchivePath=./logs/archives
maximumArchiveCount=20
archiveCompressed=true
EmailLogger

An EmailLogger takes log messages and sends them out as e-mail to a list of recipients. This is useful for system administrators who wish to be notified whenever certain parts of the system malfunction. Administrators who use e-mail-to-pager gateways can be paged when certain critical events take place.

The EmailLoggerbatches log messages before sending them as e-mail. This is extremely valuable in situations where the system malfunctions in such a way that it is generating many error messages in a short amount of time. In such a situation, an administrator will find it much more helpful to receive, say, 10 pieces of e-mail with 100 error messages in each, than to receive 1000 messages with 1 error in each. The logger can be triggered to send its batched log messages when a certain number of messages have been batched, or after a certain amount of time has passed.

When the logger sends its e-mail message, it generates an EmailEvent, which is then sent to an EmailSender.

The following properties control the configuration of an EmailLogger:

A sample EmailLogger can be found at /atg/dynamo/service/logging/EmailLog:

$class=atg.nucleus.logging.EmailLogger
emailListeners=../SMTPEmail
logEventThreshold=10
scheduler=../Scheduler
schedule=every 5 minutes
defaultRecipients=sysadmin@example.com,test@example.com
defaultFrom=Dynamo_Number_12
defaultSubject=Main Reactor Core Down
defaultBody=Run now!
 
loading table of contents...