mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
@@ -23,8 +23,21 @@ public class LogFactory {
|
||||
private static Constructor logConstructor;
|
||||
|
||||
static {
|
||||
// TODO add slf4j logging
|
||||
|
||||
String logType= System.getProperty("druid.logType");
|
||||
if(logType != null){
|
||||
if(logType.equalsIgnoreCase("slf4j")){
|
||||
tryImplementation("org.slf4j.Logger", "com.alibaba.druid.support.logging.SLF4JImpl");
|
||||
}else if(logType.equalsIgnoreCase("log4j")){
|
||||
tryImplementation("org.apache.log4j.Logger", "com.alibaba.druid.support.logging.Log4jImpl");
|
||||
}else if(logType.equalsIgnoreCase("log4j2")){
|
||||
tryImplementation("org.apache.logging.log4j.Logger", "com.alibaba.druid.support.logging.Log4j2Impl");
|
||||
}else if(logType.equalsIgnoreCase("commonsLog")){
|
||||
tryImplementation("org.apache.commons.logging.LogFactory",
|
||||
"com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl");
|
||||
}else if(logType.equalsIgnoreCase("jdkLog")){
|
||||
tryImplementation("java.util.logging.Logger", "com.alibaba.druid.support.logging.Jdk14LoggingImpl");
|
||||
}
|
||||
}
|
||||
// 优先选择log4j,而非Apache Common Logging. 因为后者无法设置真实Log调用者的信息
|
||||
tryImplementation("org.apache.log4j.Logger", "com.alibaba.druid.support.logging.Log4jImpl");
|
||||
tryImplementation("org.apache.logging.log4j.Logger", "com.alibaba.druid.support.logging.Log4j2Impl");
|
||||
|
||||
Reference in New Issue
Block a user