Commons-logging cannot be used properly with log4j logs

Source: Internet
Author: User

Recently, I encountered a problem where using commons-logging in combination with log4j logs could not be normally input to the console and files. I 'd like to share the results with you.

Because the referenced jar packages are all copied from previous projects, the unused jar packages are not excluded.

This is because slf4j is used to print logs for all the company's products. However, if commons-logging is used, the following JAR Packages may cause problems.

Jcl-over-slf4j.jar

By default, logfactory of slf4 is used to create logs. Therefore, commons-logging is invalid.

 

Can I just remove this jar? Although you can now use commons-logging to output logs. properties configuration output log, and the log name is jxl. log, this log is obviously generated by operating the Excel jxl log, so find jxl. jar


It is found that the log4jlogger. Class of jxl overwrites the log4j configuration and applies the jxl configuration. Therefore, we cannot output logs according to our own log4j. properties, unlessProgramManually load log4j. properties. Otherwise, log4j. properties under classpath cannot be loaded by default.

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.