Content deleted Content added
GreenC bot (talk | contribs) Rescued 1 archive link; reformat 1 link. Wayback Medic 2.5 per Category:All articles with dead external links - pass 3 |
|||
(13 intermediate revisions by 11 users not shown) | |||
Line 8:
Logging refers to the recording of activity by an application and is a common issue for development teams. Logging frameworks ease and standardize the process of logging for the Java platform. In particular they provide flexibility by avoiding explicit output to the console (see Appender below). Where logs are written becomes independent of the code and can be customized at runtime.
Unfortunately the [[Java Development Kit|JDK]] did not include logging in its original release so by the time the Java Logging API was added several other logging frameworks had become widely used
==Functionality overview==
Line 17:
* The framework then hands the formatted message to the appropriate Appender/Handler for disposition. This might include output to a console display, writing to disk, appending to a database, or generating an email.
Simpler logging frameworks, like [https://web.archive.org/web/20020602114537/http://www.theobjectguy.com/javalog/ |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
====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
For example, the logger might be named "<code>com.sun.some.UsefulClass</code>". The handler can be defined for any of the following:
Line 63:
Severity levels can be assigned to both loggers and appenders. Both must be enabled for a given severity level for output to be generated. So a logger enabled for debug output will not generate output if the handler that gets the message is not also enabled for debug.
===Filters===
Filters cause a log event to be ignored or logged. The most commonly used filter is the logging level documented in the previous section. Logging frameworks such as Log4j 2 and SLF4J also provide Markers, which when attached to a log event can also be used for filtering. Filters can also be used to accept or deny log events based on exceptions being thrown, data within the log message, data in a ThreadLocal that is exposed through the logging API, or a variety of other methods.
===Formatters, Layouts or renderers===
Line 72 ⟶ 76:
* write to a file or syslog
* append to a database table
* distribute via [[Java messaging service|Java Messaging Services]]
* send via email
* write to a socket
Line 87 ⟶ 91:
! Cost / Licence
|-
! Log4j
| Logging Framework
| <code>FATAL ERROR WARN INFO DEBUG TRACE</code>
Line 104 ⟶ 108:
| Logging Framework
| <code>ERROR WARNING INFO DEBUG TRACE</code>
| ConsoleWriter, FileWriter, LogcatWriter, JdbcWriter, RollingFileWriter, SharedFileWriter and ''null'' (discards all log entries) <ref>{{cite web|title=User manual of tinylog|url=http://www.tinylog.org/user-manual|archive-url=https://archive.today/20130415233343/http://www.tinylog.org/user-manual|url-status=dead|archive-date=April 15, 2013}}</ref>
|
| Apache License, Version 2.0
|-
! [http://logback.qos.ch/ Logback]
Line 112 ⟶ 116:
| <code>ERROR WARN INFO DEBUG TRACE</code>
| Too many to list: see [http://logback.qos.ch/apidocs/ch/qos/logback/core/Appender.html Appender JavaDoc]
| Developed as a replacement for
| [[LGPL]], Version 2.1
|-
! [[Apache Commons Logging]] (JCL)
| Logging Wrapper
| <code>FATAL ERROR WARN INFO DEBUG TRACE</code>
| Depends on the underlying framework
| Widely used, often in conjunction with
| Apache License, Version 2.0
|-
Line 125 ⟶ 129:
| Logging Wrapper
| <code>ERROR WARN INFO DEBUG TRACE</code>
| Depends on the underlying framework, which is pluggable. Provides API compatible [[Shim_(computing)|shims]] for JCL, JDK and
| Widely used in many projects and platforms, frequently with Logback as the implementation.
| [[MIT License]]
Line 146 ⟶ 150:
==See also==
*[[SLF4J]]
*[[
*[[logback]]
*[[Javolution]] LogContext based on [http://javolution.org/apidocs/javolution/context/package-summary.html#package_description context programming] (actual logging framework selectable at run-time).
Line 160 ⟶ 164:
* [http://java-source.net/open-source/logging Open Source Logging Tools in Java]
* [http://apache.org/licenses/LICENSE-2.0 The Apache 2.0 license.]
* [http://logback.qos.ch/ Logback - A successor to the popular
* [http://www.tinylog.org/ tinylog - Minimalist logging utility with a static logger]
* [http://loggifier.unkrig.de Loggifier] A tool that inserts logging code into .class, .jar and .ear files
|