Java logging framework: Difference between revisions

Content deleted Content added
fix tinylog licence
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
 
(10 intermediate revisions by 8 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 - in particular [http://commons.apache.org/logging Apache Commons Logging] (also known as Java Commons Logging or JCL) and [[log4jLog4j]]. This led to problems when integrating different third-party libraries (JARs) each using different logging frameworks. Pluggable logging frameworks (wrappers) were developed to solve this problem.
 
==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===
Line 23:
 
====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]]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:
Line 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 91:
! Cost / Licence
|-
! Log4j
! [[Log4J]]
| Logging Framework
| <code>FATAL ERROR WARN INFO DEBUG TRACE</code>
Line 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
Line 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 log4jLog4j, with many improvements. Used by numerous projects, typically behind slf4j, for example [[Akka (toolkit)|Akka]], [[Apache Camel]], [[Apache Cocoon]], [[Artifactory]], [[Gradle]], [[Lift (web framework)|Lift Framework]], [[Play Framework]], [[Scalatra]], [[SonarQube]], [[Spring_Framework#Spring_Boot|Spring Boot]], ...
| [[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 log4jLog4j
| Apache License, Version 2.0
|-
Line 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 log4jLog4j logging packages. It can also use any of them to generate output. Defaults to using Logback for output if available.
| Widely used in many projects and platforms, frequently with Logback as the implementation.
| [[MIT License]]
Line 150:
==See also==
*[[SLF4J]]
*[[log4jLog4j]]
*[[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 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 log4jLog4j project]
* [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