Log4j and JCL

Source: Internet
Author: User
Tags log log log4j

What's JCL?

When we are logging, we often use log4j or JDK1.4 in the future, but what is JCL, JCL is Jakarta Commons log tool, he is a bridge between various logging tools, Commons-logging helps you to switch log tools without recompiling the program, such as by switching the JDK built-in log tool to the log4j log tool;

JCL can be downloaded to the http://jakarta.apache.org/commons/logging site;

How to use JCL

JCL mainly consists of two important components, org.apache.commons.loggging.LogFactory (a specific factory class) and his return instance, This example implements the Org.apache.commons.logging.Log interface, JCL configuration is the least, in most cases, you only need to put Commons-logging.jar pack under Classpath; Logfactory provides excellent log detection capabilities, he First you will find the Log4j.jar below the classpath if you don't find it, you will find the jdk1.4+ version;

In the code, we just type:

Import Org.apache.commons.logging.Log; Import Org.apache.commons.logging.LogFactory; ... private static log log = Logfactory.getlog (Testthread.class);

And when we use log4j, we must use:

Import Org.apache.log4j.Logger; .... private Logger log = Logger.getlogger (Testthread.class);.

The log4j and code have to be strongly coupled;

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.