@@ -45,19 +45,19 @@ public static Log getLog(Class<?> aClass) {
45
45
}
46
46
47
47
public static synchronized void useSlf4jLogging () {
48
- setImplementation ("org.slf4j.LoggerFactory" , "org. apache.ibatis.logging.slf4j.Slf4jImpl" );
48
+ setImplementation ("org.apache.ibatis.logging.slf4j.Slf4jImpl" );
49
49
}
50
50
51
51
public static synchronized void useCommonsLogging () {
52
- setImplementation ("org.apache.commons.logging.LogFactory" , "org.apache. ibatis.logging.commons.JakartaCommonsLoggingImpl" );
52
+ setImplementation ("org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl" );
53
53
}
54
54
55
55
public static synchronized void useLog4JLogging () {
56
- setImplementation ("org.apache.log4j.Logger" , "org.apache. ibatis.logging.log4j.Log4jImpl" );
56
+ setImplementation ("org.apache.ibatis.logging.log4j.Log4jImpl" );
57
57
}
58
58
59
59
public static synchronized void useJdkLogging () {
60
- setImplementation ("java.util.logging.Logger" , " org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl" );
60
+ setImplementation ("org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl" );
61
61
}
62
62
63
63
public static synchronized void useStdOutLogging () {
@@ -79,15 +79,13 @@ private static void tryImplementation(Runnable runnable) {
79
79
}
80
80
81
81
private static void setImplementation (String implClassName ) {
82
- setImplementation (implClassName , implClassName );
83
- }
84
-
85
- private static void setImplementation (String testClassName , String implClassName ) {
86
82
try {
87
- Resources .classForName (testClassName );
88
83
@ SuppressWarnings ("unchecked" )
89
- Class <? extends Log > implClass = (Class <Log >) Resources .classForName (implClassName );
90
- logConstructor = implClass .getConstructor (new Class []{Class .class });
84
+ Class <? extends Log > implClass = (Class <? extends Log >) Resources .classForName (implClassName );
85
+ Constructor <? extends Log > candidate = implClass .getConstructor (new Class []{Class .class });
86
+ Log log = candidate .newInstance (new Object []{LogFactory .class });
87
+ log .debug ("Logging initialized using '" + implClassName + "' adapter." );
88
+ logConstructor = candidate ;
91
89
} catch (Throwable t ) {
92
90
throw new LogException ("Error setting Log implementation. Cause: " + t , t );
93
91
}
0 commit comments