spring日志的选择

common-logging

在springframework的spring-core中强制指定了使用common-logging模块,该模块是标准的实现至Jarka Common Log(JCL)的,并在runtime运行时自动发现其它框架选择的日志组件,并定位一个认为最接近的日志组件作为应用日志(如果什么都没找到,会使用JDK的LOG,(java.util.logging or JUL for short)),在maven中只需要配置了spring-core就有了


  
    org.springframework
    spring-core
    4.2.5.RELEASE
  

SLF4J

使用SLF4J(Simple Log Factory For JAVA)需要将common-logging排除,同时需要使用SL4J桥接,将springframework的common-logging桥接到SL4J上,所以需要4个依赖,同时排除spring-core中自带的common-logging,使用maven如下


  
    org.springframework
    spring-core
    4.2.5.RELEASE
    
      
         commons-logging
        commons-logging
      
    
  
  
    org.slf4j
    jcl-over-slf4j
    1.5.8
  
  
    org.slf4j
    slf4j-api
    1.5.8
  
  
    org.slf4j
    slf4j-log4j12
    1.5.8
  
  
    log4j
    log4j
    1.2.14
  

log4j

使用log4j时不需要排除spring-core中的common-logging,同时log4j也是运行时绑定,相当于common-logging在运行时绑定了log4j,maven如下


  
    org.springframework
    spring-core
    4.2.5.RELEASE
  
  
    log4j
    log4j
    1.2.14
  

你可能感兴趣的:(spring日志的选择)