log4jdbc的使用方法

[b][size=large]1.JDBC配置[/size][/b]

[size=large]log4jdbc:jdbc层的一个日志框架[/size]

maven依赖:


com.googlecode.log4jdbc
log4jdbc
1.2


以SQL Server为例,把原配置属性中的driverClass,url修改如下

#jdbc_driverClass=net.sourceforge.jtds.jdbc.Driver
jdbc_driverClass=net.sf.log4jdbc.DriverSpy
#jdbc_url=jdbc:jtds:sqlserver://localhost:1433/dbname
jdbc_url=jdbc:log4jdbc:jtds:sqlserver://localhost:1433/dbname
jdbc_username=sa
jdbc_password=123456



[size=large]2.log4j配置[/size]

log4j.logger.jdbc.sqlonly=OFF
log4j.logger.jdbc.sqltiming=INFO
log4j.logger.jdbc.audit=OFF
log4j.logger.jdbc.resultset=OFF
log4j.logger.jdbc.connection=OFF



[size=large]3.运行测试结果[/size]

[INFO][2014-08-17 21:50:48,533][jdbc.sqltiming]select organizati0_.id as id1_0_0_, organizati0_.locked as locked2_0_0_, organizati0_.name as name3_0_0_, organizati0_.parentId as parentId4_0_0_, organizati0_.code as code5_0_0_, organizati0_.type as type6_0_0_ from cz_branch organizati0_ where organizati0_.id=3
{executed in 1 msec}

你可能感兴趣的:(log4j,JDBC)