Announcement Announcement Module
Collapse
No announcement yet.
Spring with SLF4J Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring with SLF4J

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

  • #2
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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

            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

            Comment


            • #7
              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, 06:43 PM.

              Comment

              Working...
              X