Advanced use of log4j 2.0 in development (1)

Source: Internet
Author: User
Log4j finally ushered in the first apache version. Log4j 2 is an upgraded version of log4j. This version is significantly improved compared with its predecessor, including many improvements in logback and problems in the logback architecture.

This is the first release version of log4j 2. The following improvements are worth noting:

  • API separation-The log4j API and its implementation are classified (Note: I hate this, but a jar package would have to be several, like slf4j)
  • Designed for log auditing, unlike log4j 1.x and logback, log4j 2 does not lose Events During reconfiguration, and supports message auditing.
  • The performance improvement is much higher than log4j 1.x in key fields. In most cases, the performance is similar to logback.
  • Supports multiple APIs and slf4j and commons logging APIs
  • Automatic Configuration reload, supports XML and JSON format Configuration
  • Plug-in architecture. All configurable components are defined by the log4j plug-in, including appender, layout, pattern converter, and so on.
  • Configuration property support
    Apache log4j 2.0 requires at least JDK 5

    It takes a lot of planning and effort to request logs to application code. It is observed that about 4% of the code is used for logging. Therefore, even applications of the average size will have thousands of log statements embedded in their code. Because of their quantity, it has become a log statement for managing these logs without modifying manual commands.

    Log4j 2.0 contains the default configuration file with the error level. Manual or automatic configuration is available.
    Log4j 2.0 has four configuration files.
    1. XML, JSON, or yaml written in a configuration file.
    2. Create a configurationfactory and configure it programmatically.
    3. Add default configurations of components on the configuration page by calling APIs programmatically.
    4. Call the internal methods of the logger class programmatically.
    This is what we know about the features of log4j 2.0.
    If you have any questions or problems, add the QQ group: 135430763 for feedback and learn together!


Advanced use of log4j 2.0 in development (1)

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.