Java EE log4j

Source: Internet
Author: User

1, log4j is an Apache open source project, can be configured flexibly through a configuration file, without the need to modify the application code.

2, LOG4J has three main components:

  • Logger: Writes log information to one or more output sources according to the format specified in the layout;
  • Output Source: Can be a console, a text file, an XML file, or a socket, or even write to the Windows event log or send it by e-mail;
  • Layout: All classes that inherit the layout class define the layout of the log information, the so-called layout is the format of the log information.

3, there are 5 kinds of log levels in log4j:

FATAL: Output debug information for fatal error level;

Error: Output debug information at the wrong level;

WARN: Debug information for output warning level;

Info: Debug information at the output prompt level;

Debug: Output general debugging information;

4, log management in the process of running the program to provide accurate runtime context to facilitate developers to find bug;log information can be exported to different places; In addition to playing its role in the development process, a powerful enough logging development package can be used as an audit tool.

5, log information embedded in the Java code, the runtime has a certain impact on efficiency, occupy resources, increase the cost of code and unnecessary output. Therefore: the release phase as far as possible to close unnecessary debug information log, to improve the efficiency of the program run.

Java EE log4j

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.