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.