I support the complete abandonment of Commons Logging in favour of Simple Logging Facade 4 Java (SLF4J). Especially in libraries that use it – I think it’s amazing that Spring to link to it in their libraries!
For those of you that are blissfully un-aware of the hazards of the run time binding that commons logging uses and have been luckily enough not to have run into it yet – educate yourselves.
“Commons-logging promises to bridge to different logging APIs such as log4j, Avalon logkit and
java.util.loggingAPI. However, it’s dynamic discovery mechanism is the source of painful bugs.”
Apparently it’s his fault. Well mostly, as he admits:
“I’ll come right out and admit it: commons-logging, at least in its initial form, was my fault, though probably not mine alone.”
This guy deserves a medal. He freely hosts a great service for Maven users (yay! go Maven! (and Ivy and Gradle for that matter) ) that let’s you deal away with Commons Logging in your project easily.
The summary of the solution is basically:
<repositories> <repository> <id>Version99</id> <name>Version 99 Does Not Exist Maven repository</name> <layout>default</layout> <url>http://no-commons-logging.zapto.org/mvn2</url> </repository> </repositories> <dependencies> <!-- get empty jar instead of commons-logging --> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>99.0-does-not-exist</version> </dependency> </dependencies>
It’s really amaizing that something as seemingly simple as logging causes such a nightmare for so many people!
Maven issue MNG-1977 will address this issue nicely by letting you globally exclude all commons-logging dependencies across all transitive dependencies in one statement.
Please so your neighbor-hood developer a favour, and vote for it🙂