Java logging framework: Difference between revisions

Content deleted Content added
m Reverted edits by MkNbg (talk) identified as spam (HG)
No edit summary
Line 7:
In software, logging refers to the recording of activity. Logging is a common issue for development teams. Several frameworks ease and standardize the process of logging for the Java platform. This article covers general purpose logging frameworks.
 
== Functionality overview ==
Logging is broken into three major pieces: the Logger, Formatter and the Handler (Appender). The Logger is responsible for capturing the message to be logged along with certain metadata and passing it to the logging framework. After receiving the message, the framework calls the Formatter with the message. The Formatter formats it for output. The framework then hands the formatted message to the appropriate Appender for disposition. This might include a console display, writing to disk, appending to a database, or email.
 
Simpler logging frameworks, like Java Logging Framework by the Object Guy, combine the logger and the appender. This simplifies default operation, but it is less configurable, especially if the project is moved across environments.
 
=== Logger ===
A Logger is an object that allows the application to log without regard to where the output is sent/stored. The application logs a message by passing an object or an object and an [[Exception handling|exception]] with an optional severity level to the logger object under a given a name/identifier.
 
==== Name ====
A logger has a name. The name is usually structured hierarchically, with periods (.) separating the levels. A common scheme is to use the name of the class or package that is doing the logging. Both [[log4j]] and the Java logging [[API]] support defining Handlers higher up the hierarchy.
 
For example, the logger might be named "<code>com.sun.some.UsefulClass</code>". The handler can be defined for any of the following:
 
* <code>com</code>
* <code>com.sun</code>
Line 53 ⟶ 52:
The logging framework maintains the current logging level for each logger. The logging level can be set more or less restrictive. For example, if the logging level is set to "WARNING", then all messages of that level or higher are logged, ERROR and FATAL.
 
=== Formatters or renderers ===
A Formatter is an object that formats a given object. Mostly this consists of taking the binary object and converting it to a string representation.
 
=== Appenders or handlers ===
Appenders listen for messages at or above a specified minimum severity level. The Appender takes the message it is passed and posts it appropriately. Message dispositions include:
 
* display on the console
* write to a file or syslog
Line 114 ⟶ 112:
[[SLF4J]] and Logback, both originally written by the original writer of log4j, are growing potential replacements in particular for log4j and Apache Commons Logging.
 
== See also ==
 
* [[SLF4J]]
* [[Log4j]]
Line 121 ⟶ 118:
* [[Runtime Intelligence]]
 
==References==
== External links ==
{{Reflist}}
 
== External links ==
* [http://java.sun.com/javase/6/docs/technotes/guides/logging/ Java 6.0 Logging API]
* [http://jakarta.apache.org/commons/logging/ Commons Logging]
Line 130:
* [http://www.tinylog.org/ tinylog - Minimalist logging utility with a static logger]
* [http://code.google.com/p/otroslogviewer/ OtrosLogViewer - Open Source logviewer, handling standard java and custom log formats]
 
==References==
 
{{Reflist}}
 
{{DEFAULTSORT:Java Logging Framework}}