Browse Source

KERNEL-9862 fix: druid对接slf4j

feature/x
Dylan.Liu 3 years ago
parent
commit
98e85429e8
  1. 4
      fine-druid/src/main/java/com/fr/third/alibaba/druid/filter/logging/Slf4jLogFilter.java
  2. 4
      fine-druid/src/main/java/com/fr/third/alibaba/druid/support/logging/LogFactory.java
  3. 6
      fine-druid/src/main/java/com/fr/third/alibaba/druid/support/logging/SLF4JImpl.java

4
fine-druid/src/main/java/com/fr/third/alibaba/druid/filter/logging/Slf4jLogFilter.java

@ -15,8 +15,8 @@
*/ */
package com.fr.third.alibaba.druid.filter.logging; package com.fr.third.alibaba.druid.filter.logging;
import org.slf4j.Logger; import com.fr.third.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.fr.third.slf4j.LoggerFactory;
public class Slf4jLogFilter extends LogFilter { public class Slf4jLogFilter extends LogFilter {

4
fine-druid/src/main/java/com/fr/third/alibaba/druid/support/logging/LogFactory.java

@ -26,7 +26,7 @@ public class LogFactory {
String logType= System.getProperty("druid.logType"); String logType= System.getProperty("druid.logType");
if(logType != null){ if(logType != null){
if(logType.equalsIgnoreCase("slf4j")){ if(logType.equalsIgnoreCase("slf4j")){
tryImplementation("org.slf4j.Logger", "SLF4JImpl"); tryImplementation("com.fr.third.slf4j.Logger", "SLF4JImpl");
}else if(logType.equalsIgnoreCase("log4j")){ }else if(logType.equalsIgnoreCase("log4j")){
tryImplementation("org.apache.log4j.Logger", "Log4jImpl"); tryImplementation("org.apache.log4j.Logger", "Log4jImpl");
}else if(logType.equalsIgnoreCase("log4j2")){ }else if(logType.equalsIgnoreCase("log4j2")){
@ -38,13 +38,13 @@ public class LogFactory {
tryImplementation("java.util.logging.Logger", "Jdk14LoggingImpl"); tryImplementation("java.util.logging.Logger", "Jdk14LoggingImpl");
} }
} }
tryImplementation("com.fr.third.slf4j.Logger", "SLF4JImpl");
// 优先选择log4j2防止漏洞 // 优先选择log4j2防止漏洞
tryImplementation("com.fr.third.apache.logging.log4j.Logger", "FRLog4j2Impl"); tryImplementation("com.fr.third.apache.logging.log4j.Logger", "FRLog4j2Impl");
// 优先选择log4j,而非Apache Common Logging. 因为后者无法设置真实Log调用者的信息 // 优先选择log4j,而非Apache Common Logging. 因为后者无法设置真实Log调用者的信息
tryImplementation("com.fr.third.apache.log4j.Logger", "FRLog4jImpl"); tryImplementation("com.fr.third.apache.log4j.Logger", "FRLog4jImpl");
tryImplementation("org.apache.log4j.Logger", "Log4jImpl"); tryImplementation("org.apache.log4j.Logger", "Log4jImpl");
tryImplementation("org.apache.logging.log4j.Logger", "Log4j2Impl"); tryImplementation("org.apache.logging.log4j.Logger", "Log4j2Impl");
tryImplementation("org.slf4j.Logger", "SLF4JImpl");
tryImplementation("org.apache.commons.logging.LogFactory", "JakartaCommonsLoggingImpl"); tryImplementation("org.apache.commons.logging.LogFactory", "JakartaCommonsLoggingImpl");
tryImplementation("java.util.logging.Logger", "Jdk14LoggingImpl"); tryImplementation("java.util.logging.Logger", "Jdk14LoggingImpl");

6
fine-druid/src/main/java/com/fr/third/alibaba/druid/support/logging/SLF4JImpl.java

@ -15,9 +15,9 @@
*/ */
package com.fr.third.alibaba.druid.support.logging; package com.fr.third.alibaba.druid.support.logging;
import org.slf4j.Logger; import com.fr.third.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.fr.third.slf4j.LoggerFactory;
import org.slf4j.spi.LocationAwareLogger; import com.fr.third.slf4j.spi.LocationAwareLogger;
public class SLF4JImpl implements Log { public class SLF4JImpl implements Log {

Loading…
Cancel
Save