logback打印mybatis 日志

原创
2016/12/24 11:10
阅读数 5K

在mybatis3.2X 版本 mybatis 更换了打印日志的方式,在logback中使用以下方式。 logback配置文件

<configuration>
	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<!-- encoder 默认配置为PatternLayoutEncoder -->
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
			</pattern>
		</encoder>
	</appender>

	<logger name="dao" level="DEBUG" />
	<logger name="com.wawscm" level="INFO" />


	<root level="INFO">
		<appender-ref ref="STDOUT" />
	</root>



</configuration>  

mybatis 配置文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN"  
	"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<properties>
		<property name="dialectClass" value="com.wawscm.orm.dialect.MySql5Dialect" />
	</properties>
	<settings>
		<setting name="logPrefix" value="dao." />
	</settings>
</configuration>

最终效果

10:40:17.685 [qtp540876179-33] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ooo Using Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@24fb752f]
10:40:17.692 [qtp540876179-33] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==>  Preparing: select count(1) count FROM tbm_dict_package_type AS dpt WHERE 1 = 1 
10:40:17.693 [qtp540876179-33] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==> Parameters: 
10:40:17.698 [qtp540876179-33] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==>  Preparing: SELECT * FROM tbm_dict_package_type AS dpt WHERE 1 = 1 ORDER BY dpt.create_time DESC limit 0 ,15 
10:40:17.699 [qtp540876179-33] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==> Parameters: 
10:55:59.604 [qtp540876179-33] INFO  o.a.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set.  Authorization cache cannot be obtained.
10:55:59.605 [qtp540876179-33] INFO  o.a.s.cache.ehcache.EhCacheManager - Using existing EHCache named [authorizationCache]
10:55:59.881 [qtp540876179-35] INFO  o.a.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set.  Authorization cache cannot be obtained.
10:55:59.881 [qtp540876179-35] INFO  o.a.s.cache.ehcache.EhCacheManager - Using existing EHCache named [authorizationCache]
10:56:04.089 [qtp540876179-35] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ooo Using Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@24fb752f]
10:56:04.089 [qtp540876179-35] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==>  Preparing: select count(1) count FROM tbm_dict_package_type AS dpt WHERE 1 = 1 
10:56:04.090 [qtp540876179-35] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==> Parameters: 
10:56:04.106 [qtp540876179-35] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==>  Preparing: SELECT * FROM tbm_dict_package_type AS dpt WHERE 1 = 1 ORDER BY dpt.create_time DESC limit 0 ,15 
10:56:04.106 [qtp540876179-35] DEBUG d.c.w.m.d.m.D.findDictPackageTypeByPage - ==> Parameters: 
展开阅读全文
打赏
0
2 收藏
分享
加载中
更多评论
打赏
0 评论
2 收藏
0
分享
返回顶部
顶部