October 2018
Intermediate to advanced
590 pages
15h 5m
English
In this section, we will introduce one way to log the SQL queries that JdbcDriver sends to the database. We will use P6Spy (https://github.com/p6spy/p6spy).
The first change we need to make is to add the following dependencies into pom.xml:
<dependency> <groupId>p6spy</groupId> <artifactId>p6spy</artifactId> <version>${p6spy.version}</version></dependency>
At the time of writing, the P6Spy version we use is 3.7.0. To customize P6Spy, we can add the src/main/resources/spy.properties configuration file. The one that we will use looks as follows:
driverlist=com.mysql.jdbc.Driverlogfile=spy.logdateformat=yyyy-MM-dd HH:mm:ss.SSlogMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormatcustomLogMessageFormat ...
Read now
Unlock full access