title say it everything. I want to log my sql queries but the problem is, at each program restart it append query in same file because I'm specifying the same in my spy.properties file:
driverlist=com.mysql.cj.jdbc.Driver
dateformat=yyyy-MM-dd HH:mm:ss.SSSS
appender=com.p6spy.engine.spy.appender.FileLogger
logfile=C:\\Users\\manis\\Documents\\log\\dblog\\spy.log
logMessageFormat=com.p6spy.engine.spy.appender.SingleLineFormat
I want log file to have name something like this: spy_TIMESTAMP.log
I m using JDBC for db connection.
P6Spy does not support that functionality out of the box, but one thing you could do is to override values from
spy.properties
passing system properties-Dp6spy.config.logfile=myuniquefile.log
or from the code:but it should happen before JDBC driver initialisation.