Third-party class libraries: Use the efficient log tool-Log4J

Source: Internet
Author: User

Some log operations, such as debugging information in the development stage, running logs, and auditing, are often used during programming. The survey shows that the Log Code accounts for 4% of the total code. Generally, you can simply use the System. out. println () statement to output log information, but there are usually some judgments, such:

  1. If(SomeCondition ){
  2.  System. Out. println ("some information .");
  3. }


These judgments cause a large number of output statements to be mixed in the normal program logic. These judgments written in the development stage are only for debugging statements and need to be searched and removed after development is complete. After deployment and operation, especially in some enterprise application systems, further debugging is often required, which leads to greater troubles. Therefore, we need a complete, flexible, and configurable log tool. Log4J is an excellent choice.

Log4J is a sub-project under the Jakarta project of the Apache Software Foundation and an excellent log toolkit written in Java. With Log4J, you can enable or disable log information of any granularity conveniently and flexibly without modifying the code, and then use the custom format, output the log information to one or more required places. In addition, Log4J also has a smooth learning curve, which can be easily used within three minutes. With in-depth use, you will find that Log4J is powerful and can meet almost all log needs.


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.