Results 1 to 6 of 6

Thread: Simpler way to exlude commons-logging in Spring

Threaded View

  1. #1

    Default Simpler way to exlude commons-logging in Spring

    Chapter 1 of the Spring documentation, more precisely section 1.3.2.1, describes a strategy of replacing commons-logging with slf4j. The described strategy uses maven exclusions. I think a considerably simpler and more robust strategy is to declare commons-logging in the provided scope. The actual commons-logging classes would be provided by jcl-over-slf4j. This translates into the following pom file snippet:

    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
    </dependency>

    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.6.1</version>
    </dependency>

    The first dependency declaration essentially states that commons-logging will be "somehow" provided by the user's environment. The second declaration includes jcl-over-slf4j into your project. As jcl-over-slf4j is a perfect binary-compatible replacement for commons-logging, the first assertion becomes true.

    This approach covers all dependencies using commons-logging with just one declaration whereas with the explicit exclusion approach commons-logging needs to be explicitly excluded in every dependency depending on common-logging.
    Last edited by Ceki Gülcü; Nov 10th, 2010 at 12:28 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •