Craftsman Spy JDBC Driver 1.0.5
"My job consist to listen all the communications with discretion. So after I must report them to my superiors."
An anonymous spy

Features

Craftsman Spy is an open source and free framework for JDBC logging. It is a JDBC driver implementation.

This logger logs all SQL connection and processings with execution spent time, all the stored procedures with arguments, all the batch processings and the result sets.

No need to modify your application in order to integrate JDBC logging with Craftsman Spy. The application MUST use the craftsman.spy.SpyDriver and MUST be launched with the -Dspy.driver=... system property.

Be carefull this JDBC driver SHOULD not be used in production mode. Use it only in development or pre-production system.

Using

Code

The two solutions can be used as the following examples :
System.setProperty("spy.driver","vendor.database.Driver");// or with the -Dspy.driver=vendor.database.Driver JVM option
Class.forName("craftsman.spy.SpyDriver");
Connection c = DriverManager.getConnection("jdbc:database:mydata");
Class.forName("craftsman.spy.SpyDriver");
Connection c = DriverManager.getConnection("jdbc:spy:vendor.database.Driver:database:mydata");

Log configuration

The log4j.properties or log4j.xml configuration file SHOULD contain the following lines :
log4j.category.craftsman.spy=DEBUG, SpyFile
log4j.appender.SpyFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.SpyFile.DatePattern='.'yyyy.MM.dd
log4j.appender.SpyFile.File=spy.log
log4j.appender.SpyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.SpyFile.layout.ConversionPattern=%m%n

Download

Dependencies

Todo