Results 1 to 7 of 7

Thread: Spring with SLF4J

  1. #1
    Join Date
    Aug 2007
    Posts
    1

    Default Spring with SLF4J

    I want to use SLF4J for logging instead of commons-logging. How do I configure?

  2. #2
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    No way. Commons-logging is the only Spring hard dependency.
    To be more precious you may use SLF4J in your own code, but you still need commons-logging for Spring itself.

  3. #3
    Join Date
    Apr 2005
    Location
    Italy
    Posts
    95

    Default

    There is a way.

    You could always update the Spring source and recompile.

    With global search and replace this wouldn't be such a big deal.

  4. #4
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by derek View Post
    There is a way.

    You could always update the Spring source and recompile.

    With global search and replace this wouldn't be such a big deal.
    Yes, if you will to do it with each new release.

  5. #5
    Join Date
    Dec 2005
    Posts
    935

    Default

    Just use the SLF4J jcl104-over-slf4j jar as a drop-in replacement for the commons-logging jar. With this you can get all the benefits of SLF4J and still use the exact same commons-logging API - ie no changes in your code.

    If you use Maven, the dependency is as follows:
    Code:
    <dependency>
    	<groupId>org.slf4j</groupId>
    	<artifactId>jcl104-over-slf4j</artifactId>
    	<version>1.4.2</version>
    </dependency>
    Alan

  6. #6
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    There is one problem - Spring relies on commons-logging 1.1, not 1.0.4,
    so I'm not sure that suggested drop-in would suffice.

    Regards,
    Oleksandr

    Quote Originally Posted by aks View Post
    Just use the SLF4J jcl104-over-slf4j jar as a drop-in replacement for the commons-logging jar. With this you can get all the benefits of SLF4J and still use the exact same commons-logging API - ie no changes in your code.

    If you use Maven, the dependency is as follows:
    Code:
    <dependency>
    	<groupId>org.slf4j</groupId>
    	<artifactId>jcl104-over-slf4j</artifactId>
    	<version>1.4.2</version>
    </dependency>
    Alan

  7. #7
    Join Date
    Dec 2005
    Posts
    935

    Default

    There is one problem - Spring relies on commons-logging 1.1, not 1.0.4,
    so I'm not sure that suggested drop-in would suffice.
    I don't think the version matters too much, as we haven't had a problem, moreover, the API from 1.0.4 to 1.1 is little different and slf4j is providing the engine underneath anyway. However, commons-logging 1.1 (and 1.1.1) are supposed to fix the class loading issues that have caused people to move away from it to frameworks like slf4j. I'm going to try it out and see how it goes
    Alan
    Last edited by Alan Stewart; Aug 6th, 2007 at 05:43 PM.

Posting Permissions

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