Content deleted Content added
→Summary: Claim without proof. |
Thumperward (talk | contribs) initial tidying |
||
Line 1:
'''Java logging frameworks''' are [[computer data logging]] packages for the [[Java platform]].
== Functionality overview ==▼
▲==Functionality overview==
Logging a message is broken into three major pieces: the Logger, Formatter and the Appender (Handler). The Logger is responsible for capturing the message to be logged, along with certain meta-data like level, and passing that to the logging framework. After receiving the message, the logging framework calls the Formatter on the message. The Formatter accepts an object and formats it for proper logging. The logging framework then hands the formatted message to the appropriate Appender for disposition of the message. This might include displaying on a console, writing to disk, appending to a database, or notification via email.
Simpler logging frameworks, like Java Logging Framework by the Object Guy, combine the logger and the appender together. This makes for simple initial configuration, but less configurable, especially as the project is moved across environments.
=== Logger ===
Most frameworks support the notion of a Logger. A Logger is an object that allows the application to log data without regard to where the data is actually logged. The application logs a message in the form of an object or an object and exception. When a Logger is created, it is given a name or an identifier. When logging a message, it is logged at a certain level or priority.
====Name====▼
▲==== Name ====
A logger has a name. The name is usually hierarchical, with periods (.) separating the levels. A common naming scheme is to use the name of the class or package that is doing the loggings. Both [[log4j]] and the Java API supported defining Handlers higher up the hierarchy.
For example, the logger might be named "com.sun.some.UsefulClass". The handler can be defined for any of the following:
* com
* com.sun
Line 18 ⟶ 24:
* com.sun.some.UsefulClass
==== Level ====
The message is logged at a certain level. The common levels are, copied from [http://jakarta.apache.org/commons/logging/guide.html#Message_Priorities_Levels Jakarta Commons Logging]:
{| border=1 cellspacing=0 cellpadding=5
Line 41 ⟶ 48:
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
A Formatter is an object that formats a given object for logging by the Appender. Mostly this consists of taking the object and converting it to a string representation.
=== Appenders or
The appenders are configured to listen for messages of a certain log level or above. The Appender takes the message it is passed and disposes of the messages. Some message dispositions include:
* display on the console
* write to a file or syslog
Line 54 ⟶ 64:
* bit-bucket (/dev/null)
==Comparing
{| border=1
| ''Feature''
Line 85 ⟶ 96:
==Summary==
{{POV-section|date=December 2007}}
Of the major players, [[log4j]] is still the front runner in the [[Java]] [[Logging]] ___domain{{Fact|date=June 2008}}. The log4j project has been around for a long time and has lots of support from the development community. It's simple to implement, yet has powerful tools built in to accomplish most logging tasks. It is also easily extensible to handle proprietary needs.
Line 93 ⟶ 105:
[[SLF4J]] and [[Logback]], both originally written by the same original writer of [[log4j]], are growing potential replacements in particular for log4j and Jakarta Commons Logging.
* [http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/ Java 1.4 Logging API]▼
* [http://jakarta.apache.org/commons/logging/ Commons Logging]▼
* [[SLF4J]]
* [[Log4j]]
== External links ==
▲* [http://java.sun.com/
▲* [http://jakarta.apache.org/commons/logging/ Commons Logging]
* [http://protomatter.sourceforge.net Protomatter]
* [http://www.theobjectguy.com/javalog The Object Guy's Logging Framework]
▲See also:
* [http://java-source.net/open-source/logging Open Source Logging Tools in Java]
* [http://www.developer.com/java/other/article.php/1404951 Logging in Java Applications] article by Thornton Rose
|