Previous | Next | |
5.5 Configuring Logging
No logging is output by a KineticFusionServerType object unless explicitly defined however users can add one or more logging objects to the the application to capture log output.
5.5.1 Capturing Text Output
To capture all the text output that is logged by the application, the KineticFusionServerFactory provides the following methods:
/** * Add a global logging appender to the logging system. This appender will * receive output from all active threads. This method should not be used for * Commons Logging as the KineticFusion application cannot create proxy log objects * for Commons Logging * * @param appender * @throws KineticFusionException * if any exception occurs. The cause of the exception can be * retrieved by calling getCause() */ public void addLoggingAppender(LoggingAppender appender) throws KineticFusionException; /** * Add a global log event appender to the logging system. This appender will * receive output from all active threads. This method should not be used for * Commons Logging as the KineticFusion application cannot create proxy log objects * for Commons Logging * * @param appender * @throws KineticFusionException * if any exception occurs. The cause of the exception can be * retrieved by calling getCause() */ public void addLoggingAppender(LogEventAppender appender) throws KineticFusionException; /** * Add a global console log appender to the logging system * * @throws KineticFusionException * if any exception occurs. The cause of the exception can be * retrieved by calling getCause() */ public void addConsoleLogger() throws KineticFusionException;
These methods allow the use to add logging appender objects that will receive all output from the logging system. THere are two possible logging appenders that can be implemented:
- com.kinesis.log.LoggingAppender
- All messages handled by this classes are already preformatted and suitable for file or console output.
- com.kinesis.log.LogEventAppender
- All message handled by this class are in their raw form and can be formatted and filtered by the appender instance.
5.5.1.1 Using a LoggingAppender
The LoggingAppender interface provides the following two methods:
/** * Append text to the log * @param text */ public void append(String text); /** * Close the appender */ public void close();
An OutputStreamLogAppender is illustrated below (provided as an inner classes in the KineticFusionServerTest example):
/** * Logging class to write all logging output to a PrintStream object. This * can be easily used to log to stdout or stderr. */ static private final class OutputStreamLogAppender implements LoggingAppender { private final PrintStream myStream; public OutputStreamLogAppender(PrintStream stream) { myStream = stream; } /** * Simply write all logged text to the local PrintStream * * @param text */ public void append(String text) { myStream.println(text); } /** * Close does nothing since we are may not wish to close stdout/stderr. */ public void close() { } }
5.5.1.2 Using The LogEventAppender
Alternatively, the user can choose to process generated raw log events. An additional logging interface is provided to subscribe to raw logging events, com.kinesis.logging.LogEventAppender, that can be implemented by the user. This interface provides the following methods:
/** * Log a logging event to the appender * @param event */ public void appendEvent(LogEventType event); /** * Close the appender when the application terminates */ public void close();
The com.kinesis.log.LogEventType interface provides methods for accessing all the information stored in a single log event. The moethds provided are:
/** * Get the time in milliseconds for the log message * @return The number of milliseconds since Jan 01 1970 */ public long getEventTime(); /** * Return the priority of the message * @return The priority of the message */ public LogPriority getMessagePriority(); /** * Get the text of the message * @return The text of the message */ public String getMessage();
5.5.1.3 Enabling the Console
By default, there is no logging output from the KineticFusion Server component. To enable all logging to stdout, the addConsoleLogger() method can be called. This will immediately copy all log output to the console. To remove the console, the removeAllAppenders() method must be used.
5.5.2 Logging ActionScript Messages
ActionScript messages can be logged when the configuration option kinesis.logging.logActionScriptToConsole is enabled. However, it is possible to get more information on these messages by processing the ActionScript messages that are returned in the ResultType instance when classes or RVML documents are processed. See the processing section for more information.
Previous | Next |
Copyright 2003-2005 Kinesis Software. All rights reserved.