File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 59
59
WebSphere的环境中——WebSphere提供了Commons Logging的私有实现,你的Log4J配置将被忽略。
60
60
这种做法不免让人悲催,MyBatis怎么能忽略你的配置呢?事实上,因Commons Logging已经存
61
61
在了,按照优先级顺序,Log4J自然就被忽略了!不过,如果你的应用部署在一个包含Commons Logging的环境,
62
- 而你又想用其他的日志框架,你可以根据需要调用如下的某一方法:
62
+ 而你又想用其他的日志框架,你可以通过在MyBatis的配置文件mybatis-config.xml里面添加一项setting(配置)来选择一个不同的日志实现。
63
+ </p >
64
+ <source ><![CDATA[ <configuration>
65
+ <settings>
66
+ ...
67
+ <setting name="logImpl" value="LOG4J"/>
68
+ ...
69
+ </settings>
70
+ </configuration>]]>
71
+ </source >
72
+ <p >
73
+ logImpl可选的值有:SLF4J、LOG4J、LOG4J2、JDK_LOGGING、COMMONS_LOGGING、STDOUT_LOGGING、NO_LOGGING
74
+ 或者是实现了接口<code >org.apache.ibatis.logging.Log</code >的类的完全限定类名,
75
+ 并且这个类的构造函数需要是以一个字符串(String类型)为参数的。
76
+ (可以参考org.apache.ibatis.logging.slf4j.Slf4jImpl.java的实现)
77
+ </p >
78
+ <p >
79
+ 你根据需要调用如下的某一方法:
63
80
</p >
64
81
<source ><![CDATA[ org.apache.ibatis.logging.LogFactory.useSlf4jLogging();
65
82
org.apache.ibatis.logging.LogFactory.useLog4JLogging();
You can’t perform that action at this time.
0 commit comments