Chapter 11. Logging

There are many times where it is useful or even necessary to peer inside a program and observe what it is doing. The most complete way to do this is with a debugger, such as the one included in Eclipse. This is not always a possible or practical solution for many reasons, not the least of which is that there is no way to run a production system in a debugger. Therefore, it must become the program’s task to report on its internal state. In the most general sense this task is called logging.

An obvious and much-used technique to log information is to liberally sprinkle println() statements throughout a program. However, this approach quickly proves to be insufficient for many reasons.

Printing all log messages ignores the fact ...

Get Apache Jakarta and Beyond: A Java Programmer’s Introduction 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.