"Java Common Tool Class" log4j one: log4j super Quick Start __java

Source: Internet
Author: User
Tags log log log4j
1. Get Log4j.jar Download Log4j.zip address: Http://labs.mop.com/apache-mirror/logging/log4j/1.2.17/log4j-1.2.17.zip decompression Log4j.zip , Get Log4j-1.2.17.jar
2. Rely on Log4j-1.2.17.jar in Eclipse
Right-click the project--build path--Configure build path--libraries-Add External JARs ... --Select log4j-1.2.17.jar--to determine ...
3. Configure Log4j.properties
1. Create a new file in the SRC directory in the project Log4j.properties steps are as follows: Right-click src--new--file--in File Name: Enter log4j.properties---OK ... 2. Add content to Log4j.properties:
Log4j.rootlogger=info, stdout
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
Log4j.appender.stdout.layout.conversionpattern=%5p [%t] (%F:%l)-%m%n
OK, then you can use, specifically for the care of this configuration, and then analysis
4. New test file Test.java

import Org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

Public class Test {

Static        Log log = Logfactory.getlog (Test.class);  Public void log () {

Log.debug ("Debug Info.");

Log.info ("info info");

Log.warn ("Warn info");

Log.error ("error info");

Log.fatal ("Fatal info");

}

/**

* @param args

*/

Public Static void Main (string[] args) {

Test test = new test ();

Test.log ();

}

Run and see the results ... OK, you already know how to use the following, let's see why we use this.

—— —— —— EOF —— —— ——
Author: Bi Xiaobong | HTTP://BLOG.CSDN.NET/WIRELESSQA e-mail: wirelessqa.me@gmail.com microblogging: HTTP://WEIBO.COM/WIRELESSQA reprint, please specify the source: Bi Xiaobong-http://blog . CSDN.NET/WIRELESSQA

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.