Java 1.4 Logging API

Even if you aren’t using Java 1.4, you’ve probably heard of it and the new features that it includes. One of the new features is the logging API now included with the core library. You may be wondering what the difference is between log4j and this new library, and whether you should be using that instead.

There are several similarities between log4j and the 1.4 logging implementation. However, there are also a few major differences. Let’s look at the similarities first. Both log4j and the Java 1.4 logging implementation use a hierarchical namespace for the loggers. This allows you to configure loggers that basically align along your application’s package structure, although this is not the only way to structure the loggers.They also both support multiple levels or priorities. The 1.4 logging implementation actually contains a few more levels than log4j, though you might not ever use the extra ones because they are so fine-grained.

The differences between the two implementations are generally not big enough to cause you to miss out on important functionality. However, it does appear that log4j offers more functionality for those that really need it. More importantly, log4j works with Java Versions 1.1 and above, while the 1.4 logging implementation works only with Version 1.4. There was talk about making it backward compatible, but that hasn’t happened yet and may never happen. Also, there are currently many more appender types available for log4j than for ...

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.