The simplest log4 demo program in the world

Source: Internet
Author: User

First download the package required by log4.

Write countProgramRun it. The principle is not to mention, there are a lot of online.

Package untitled9;

Import org. Apache. log4j .*;

Public class testlog4j {
Static logger log = logger. getlogger (testlog4j. Class. getname ());
Public static void main (string ARGs []) {
Basicconfigurator. Configure ();
// Logging methods
Log. debug ("Start of main ()");
Log.info ("just testing a log message with priority set to Info ");
Log. Warn ("just testing a log message with priority set to warn ");
Log. Error ("just testing a log message with priority set to error ");
Log. Fatal ("just testing a log message with priority set to fatal ");
// Another inconvenient format
Log. Log (priority. debug, "testing a log message use a alternate form ");
Log. debug ("End of main ().");
}
}

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.