Using the log4j Package
You may have heard or read about the log4j library from other sources, but in case you haven’t, let’s briefly discuss the library’s history here. Like Struts, log4j is an open source project that is part of the Jakarta set of projects. It’s essentially a set of Java classes and interfaces that provides logging functionality to multiple types of output destinations. It has been around for several years and is constantly being refined and tuned for all types of Java development. In fact, log4j has been so successful that it has been ported to several other very popular languages, including C, C++, Python, and even .NET.
Tip
At the time of this writing, log4j has released Version 1.2.5, which is its 22nd release. The next major version, 1.3, is in the works, but it won’t be released for a while. Version 1.2 is backward compatible with earlier versions, so if you are using 1.1.3, this material will still be relevant for you.
According to the creators of log4j, it was built with two central concepts
in mind: speed and flexibility. One of the distinctive features of
the logging framework is its notion of
inheritance
in categories, or
loggers as they are
now called. log4j supports a
parent/child relationship between the configured loggers in the
environment. For example, if we configured a logger for all the
classes in the com.oreilly.struts
package and
another logger for all the classes in the
com.oreilly.struts.storefront
package, the first logger would be the ...
Get Programming Jakarta Struts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.