Java Open Source Log Framework Introduction __java

Source: Internet
Author: User
Tags system log ibm developerworks log4j

In a large application system, the log is an indispensable important part, all the application error information should be able to find in the log file, some application system log may be very small, some large application system log is quite large, while the log file must be user-friendly and search, to have a high performance , or it can affect the performance of the application system.

Although logging is an essential feature of application development, the initial version of the JDK does not include logging-related APIs and implementations. Related APIs (java.util.logging, June) and implementations were not added until JDK 1.4. So in this area of logging, communities contribute a lot of open source implementations. Among them the more popular includes log4j and its successor, Logback. In addition to the true logging implementation, there is a class of logging-related encapsulation APIs, such as Apache Commons Logging and slf4j. The role of such libraries is to provide a encapsulated API hierarchy based on the logging implementation, providing a unified interface to the users of the logging API, which allows them to switch between different logging implementations freely. For example, from the JDK default logging implementation June switch to log4j. This kind of encapsulation API library is more common in the implementation of the framework, because it needs to take into account the different needs of the framework users. Less is used in actual project development, as few projects switch different logging implementations in development. In this paper, both types of libraries will be introduced concretely.


log4j

Log4j is an open source project for Apache, by using log4j, we can control the destination of log information delivery is console, file, GUI component, even interface server, NT Event recorder, UNIX syslog daemon, etc. Users can also control the output format of each log, and by defining the level of each log information, users can control the log generation process more carefully. These can be configured flexibly with a single configuration file without the need to modify the program code.

Log4j The latest version has been upgraded to version 2.0, performance than the 1.x version has improved a lot and learned some of the advantages of logback, the details can refer to the official website documentation.

Website Link: http://logging.apache.org/log4j/2.x/


Jakarta Commons Logging

Jakarta Commons Logging (JCL) provides a log (logging) interface (interface), taking into account both lightweight and not-dependent log implementation tools. It provides middleware/log tool developers with a simple log operation abstraction that allows program developers to implement tools with different specific log implementations. The user is assumed to be familiar with a higher level of detail for some kind of log implementation tool. JCL provides a simple wrapper for other log tools, including log4j, Avalon LOGKIT,JDK 1.4 (java.util.logging Packet, June), which is closer to the log4j and Logkit implementations.


Logback

Logback is another open source journaling component designed by the founder of Log4j. Logback is currently divided into three modules: Logback-core,logback-classic and logback-access. Logback-core is the base module for the other two modules. Logback-classic is an improved version of log4j. In addition, the Logback-classic full implementation SLF4J API allows you to easily replace it with other journaling systems such as log4j or JDK1.4 Logging. The Logback-access access module and the servlet container integration provide the ability to access journaling through HTTP.


slf4j

SLF4J (Simple Logging façade for Java) provides a single, unified interface for a variety of loging APIs, enabling end users to configure their desired loging APIs implementation when deployed. Logging API implementation can choose the direct implementation of SLF4J loging APIs such as: Nlog4j, Simplelogger. You can also develop appropriate adapters such as Log4jloggeradapter, Jdk14loggeradapter by using the API implementations provided by SLF4J.

Website Link: http://www.slf4j.org/



Finally, I recommend the IBM DeveloperWorks technology theme of a Daniel's article Java log management best Practices , the article on the log management has a detailed introduction, we can refer to reference.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.