LF5 User Guide Overview Features Reading Files Configuration Library Examples Troubleshoot FAQ Log4j Project Home page |
LogFactor5 Class Library
LogFactor5 is a class library that was created to enable developers to use GUI based logging with simple, non-graphical logging packages. LogFactor5 currently supports Log4J, and is JDK 1.4 compliant. The LogFactor5 classes that will be of most interest to developers are as follows: LF5Appender DefaultLF5Configurator LogMonitorBroker LogLevel LogMonitorAdapter Most users will only ever need to understand the LF5Appender and DefaultLF5Configurator classes. Advanced users may find themselves using the LogMonitorBroker and LogLevel classes if they want to spawn multiple logging console windows. ### The Basics This section provides a simple description of the classes you will probably need to use with LogFactor5. The examples provided with LogFactor5, when used in conjunction with these descriptions, should give you a good understanding of how to use the LogFactor5 logging console in your applications. #### The LF5Appender class The LF5Appender class is the main class that most LogFactor5 users will be interested in using. This class implements the org.apache.log4j.Appender interface, and extends org.apache.log4j.AppenderSkeleton. Since the LF5Appender implements the Appender interface, it can be appended to the Category tree in the same fashion as any Appender that comes with Log4J. However, the LF5Appender does not need nor support an org.apache.log4j.Layout. A Layout is not required because the LogFactor5 logging console handles all layout for you. #### The DefaultLF5Configurator The DefaultLF5Configurator class is a convenience class that can be used to quickly configure and use the LF5Appender programmatically. Calling DefaultLF5Configurator.configure( ) will register an LF5Appender at the root of the Category tree. This default configuration is loaded from a properties file in the log4j.jar. Because the default configuration is loaded from a file, there is a possibility that an IOException will be thrown by the configure( ) method. You must deal with this exception in your client code. ### Advanced Usage LogFactor5 provides the ability to log to multiple logging windows if you choose. To spawn additional logging console windows, you will need to use the LogBrokerMonitor and LogLevel classes. #### The LogBrokerMonitor class The LogBrokerMonitor is the class that allows you to create new logging windows. To create a new logging window, you will need to construct a LogBrokerMonitor object using a java.util.List that contains the supported LogLevels. Once you have created a LogBrokerMonitor, you can pass the monitor into the constructor of an LF5Appender. The monitor that you pass in will replace the instance of the LogBrokerMonitor initialized by default. If you register this LF5Appender using the Category.addAppender( ) method, you will be able to log to an additional console window. Note: You must make sure to call the show( ) method on the LogBrokerMonitor, or it will not be visible. #### The LogLevel class The LogLevel class encapsulates the various log levels that a logging library will support. For example, Log4J supports the levels fatal, error, warn, info, and debug. The JDK 1.4 will support the levels severe, warning, info, config, fine, finer and finest. The LogLevel class allows you to retrieve a java.util.List of the log levels that are supported by a specific logging implementation. To retrieve a list of the log levels supported by Log4J you need to call the static method LogLevel.getLog4JLevels( ) which returns a List of the log levels. This list should be used in the constructor of the LogBrokerMonitor that you create. The LogLevel class also allows you to dynamically add customized LogLevels. #### The LogMonitorAdapter class The LogMonitorAdapter class permits access to LogFactor5's LogBrokerMonitor with a minimal implementation effort. Using the Adapter you can create a new LogBrokerMonitor with customized LogLevels and log directly to the Monitor. The LogMonitorAdapter acts to circumvent the need for an appender. Logging requests are made to the LogMonitorAdapter and it in turn dispatches them to the LogBrokerMonitor.
Copyright © 1999-2003, Apache Software Foundation