Logging a message or exception to a channel
The LogManager provides a facility for logging messages and exceptions. What happens to those messages depends on what channel you transmit the message. Here's an example of logging a sample message to the Critical channel:
MT.getLM().log(LogManager.CRITICAL, "Database connection terminated!");
MT.getLM().log(LogManager.CRITICAL, dbException, "Database connection failed!");
Passing an exception to the log manager will cause the Stack trace to be extracted from the exception and appended to your log message if supplied. There are currently 10 default logging channels defined by the LogManager. What apollo does with messages sent to a particular channel is defined by the properties file for the Apollo Servlet. You may choose to ignore a channel completely, you assign it to go to multiple destinations (such as multiple log files, or to email). You may define your own channels to aid in classifying the log messages further; this could be used to allow a particular set of engineers monitor messages/errors/warnings from a particular part of the system. They can receive email warnings, but only for the part of the system they care about. Other channels can transmit warnings to other engineers.
Channels 1 INITIALIZATION This channel is usually used during the initialization of the Apollo System. This channel is used by the InitSystem code, and you should use this channel for any warnings or messages from the constructors on your PageBrokers. 2 SERVLET_DEBUG This channel is mostly used by apollo's runtime debugging statements 3 JINI_DEBUG This channel is mostly used by Apollo's JINI load distribution system 4 USER_DEBUG This channel should be used debugging statements in user code 5 RUNTIME_EXCEPTION This channel could be used for logging exceptions which ocour during execution 6 RUNTIME_DEBUG This channel could be used for debugging statements in user code 7 WARNING This channel could be used for non-fatal warnings 8 CRITICAL This channel could be used for failures of a critical nature 9 JOB_EXCEPTION This channel is currently used by the JobManager to log Exceptions from failed Jobs 10 EAM_DEBUG This channel is currently used by the EntryAssertionManager, and displays
Each channel is attached to a set of actions, below is a table of the actions currently implemented in apollo. You may create your own log actions by extending the LogWriter class.
STDIO Log messages are sent to STDIO STDERR Log messages are sent to STDERR, which is useful for certain debugging IDEs. ServletLog This is the logfile which your servlet execution environment (such as JServ) controls Log Messages are distributed via SMTP based email to the list of recipients
The Apollo properties files configures what Actions are bound to what channels. The method in which actions are bound to will be changing shortly to allow custom actions to be created right in the properties file. For now, however, there are only the four actions defined above.
You can see from the properties file used for the ApolloDemo website that each of the actions are assigned to the number corrisponding to the channel constant. The default channel actions are used whenever there was no explicit definition of the channel actions in the properties file.
View the org.projectapollo.demo.Demo.properties-unix file.