Chapter 9. Logging


There is life beyond System.out.println().

As applications become more sophisticated, it's important to have a mechanism for managing what can eventually become a torrent of informative and debugging information issued to the console. Over time, different systems have been developed for printing messages based on the severity or importance of the message. For example, Java defines two output streamsSystem.out for normal messages and System.err for warning messages.

Over time, a variety of toolkits have appeared to provide more sophisticated solutions, including Log4j (http://logging.apache.org/log4j/docs/) and the introduction of a logging toolkit in JDK 1.4 (http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/). These logging toolkits support a variety of levels of detail for logging events, with independently configurable options for recording these events. Unfortunately, by writing directly to a specific logging package, you risk tying your application to a toolkit that may lack needed functionality. To provide for better maintainability and flexibility, the Apache Commons Logging project allows you to separate your choice of logging toolkit from your application code and provides a minimalist default logging system (if, for example, you are running on a pre-JDK 1.4 Java virtual machine and don't have Log4j installed).



    Apache Jakarta Commons(c) Reusable Java Components
    Real World Web Services
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 137
    Authors: Will Iverson

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net