| Configuring Log4J to Work with Log4Web |
|
Log4Web will read XML-formatted messages generated by Log4J. Log4J must be configured to generate message files in a particular format, in order that those files are readable by Log4Web. Log4Web 1.0 is compatible with Log4J version 1.1. Log4Web 1.1 is compatible with Log4J versions 1.1 up to 1.2.3. Log4Web 1.2 will be compatible with any version of Log4J, provided that the XML output format remains the same. Refer to the Log4J documentation if using a more recent release of Log4J, to ensure that the Log4J developers have not modified the XML output format. Additionally, it is possible to use Log4Web in conjunction with a different logging package, provided that the logging package is able to generate XML output files conforming to the same DTD (Document Type Definition) as used by the Log4J package. The following configuration file shows a sample configuration of Log4J, in order to generate log files that Log4Web is able to read. The configuration information refers to Log4J version 1.1.3. Note that Log4J provides many other configuration options, and the reader should refer to the Log4J documentation for details of these.
This configuration states that a rolling file appender should be used. The rolling appender is useful for limiting the size of each log file. It starts a new file for log messages after a set period of time. In the above example, a new log file is started each hour. It is possible to configure the appender to begin a new file each day, or even each minute. The best configuration to select will depend on the target system, and how many messages it generates. However, as a general rule, the performance of Log4Web is inversely proportional to the size of the log files. So, smaller log files will result in faster display of the messages. The configuration also states that the output files should have a .log4j suffix. This is essential in order that Log4Web recognises the file as a messages file. Finally, the configuration states that XMLLayout should be used. Again, this is essential in order to use Log4J with Log4Web. The minimal configuration shown above may be extended to use the more powerful features of the Log4J package, provided that the rules stated above are not broken. |