标签:
一、maven依赖
<!-- 日志文件管理包 --> <!-- log start --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.0</version> <scope>compile</scope> </dependency> <!-- log4jdbc监控jdbc层 --> <dependency> <groupId>org.bgee.log4jdbc-log4j2</groupId> <artifactId>log4jdbc-log4j2-jdbc4.1</artifactId> <version>1.16</version> </dependency> <!-- slf4j相关api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.5</version> </dependency> <!-- slf4j的一个实现包 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.5</version> </dependency> <!-- log end -->
二、相关配置文件
log4jdbc.log4j2.properties
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
jdbc驱动和url修改为
db.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
db.url=jdbc:log4jdbc:mysql://localhost:3306/wechat_talk?useUnicode=true&characterEncoding=utf-8
log4j的相关配置xml或properties
使用Log4jdbc-log4j2打印mybatis的sql语句
标签:
原文地址:http://www.cnblogs.com/zaixiuxing/p/5028846.html