Monday, 4 February 2013

Maven Logging Config for Libraries & Applications

A quick dump of my standard Maven poms for both libraries & applications.

Basic theory - pipe everything to SLF4J & use Logback as the SLF4J implementation.

A library should ONLY have a dependency on slf4j-api - it should not use classes in any logging implementation.

Libraries:


  4.0.0
  com.acme
  my_library
  1.2.3

  
    1.7.1
  

  
    
      version99
      http://version99.qos.ch/
    
  

  
    
    
      org.slf4j
      slf4j-api
      ${slf4j.version}
      compile
    

    
    
      ch.qos.logback
      logback-classic
      1.0.7
      test
    
    
      org.slf4j
      jcl-over-slf4j
      ${slf4jversion}
      test
    
    
      org.slf4j
      jul-to-slf4j
      ${slf4jversion}
      test
    
    
      uk.org.lidalia
      jul-to-slf4j-config
      1.0.0
      test
    
    
      org.slf4j
      log4j-over-slf4j
      ${slf4jversion}
      test
    
    
      commons-logging
      commons-logging
      99-empty
      test
    
    
      log4j
      log4j
      99-empty
      test
    
  


  
  
  


Application:

  4.0.0
  com.acme
  my_application
  1.2.3

  
    1.7.1
  

  
    
      version99
      http://version99.qos.ch/
    
  

  
    
    
      org.slf4j
      slf4j-api
      ${slf4jversion}
      compile
    

    
    
      ch.qos.logback
      logback-classic
      1.0.7
      runtime
    
    
      org.slf4j
      jcl-over-slf4j
      ${slf4jversion}
      runtime
    
    
      org.slf4j
      jul-to-slf4j
      ${slf4jversion}
      runtime
    
    
      uk.org.lidalia
      jul-to-slf4j-config
      1.0.0
      runtime
    
    
      org.slf4j
      log4j-over-slf4j
      ${slf4jversion}
      runtime
    
    
      commons-logging
      commons-logging
      99-empty
      runtime
    
    
      log4j
      log4j
      99-empty
      runtime
    
  


  
  
  
    
       %d [%thread] %-5level %logger{36} CLIENTID=%X{CLIENTID} SESSIONID=%X{SESSIONID} USERID=%X{USERID} TRANSACTIONID=%X{TRANSACTIONID} - %msg%n
    
  
  
    
  
  

No comments:

Post a Comment