12-04-2012, 11:54 AM
Logging
ILP_J2EE_Stream_J2EE_09_Logging_V0.1.ppt (Size: 796.5 KB / Downloads: 34)
What is Java logging?
Introduced in package java.util.logging
The core package includes support for delivering plain text or XML-formatted log records to memory, output streams, consoles, files, and sockets. In addition, the logging APIs are capable of interacting with logging services that already exist on the host operating system.
Why is Java logging required?
Facilitate software servicing and maintenance at customer sites by producing log reports suitable for analysis by end users, system administrators, field service engineers, and software development teams
Capture information such as security failures, configuration errors, performance bottlenecks, and/or bugs in the application or platform
Logger and Handler
Applications make logging calls on Logger objects.
The Logger objects allocate LogRecord objects which are passed to Handler objects for publication.
LogManager
There is a global LogManager object that keeps track of global logging information
A hierarchical namespace of named Loggers
A set of logging control properties read from the configuration file
A LogManager object can be retrieved using the static LogManager.getLogManager() method
LogManager object is created during LogManager initialization, based on a system property
This property allows container applications (such as EJB containers) to substitute their own subclass of LogManager in place of the default class.
Logging can be disabled
The APIs are structured so that calls on the Logger APIs can be cheap when logging is disabled
If logging is disabled for a given log level, then the Logger can make a cheap comparison test and return
If logging is enabled for a given log level, the Logger is still careful to minimize costs before passing the LogRecord into the Handlers. In particular, localization and formatting (which are relatively expensive) are deferred until the Handler requests them. For example, a MemoryHandler can maintain a circular buffer of LogRecords without having to pay formatting costs.