Reputation: 1197
I am using p6spy to log the sql statements.we are using springboot/hibernate for Java ORM mapping.I see only select statements are getting loggged in spy.log.when insert statemnets are executing in the code I see only commmit is coming in the log but insert statements are not coming.
|connection|commit||
|connection|statement | select * from emp_id where id=1234
https://github.com/gavlyukovskiy/spring-boot-data-source-decorator
# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
# Use com.p6spy.engine.spy.appender.MultiLineFormat instead of com.p6spy.engine.spy.appender.SingleLineFormat
decorator.datasource.p6spy.multiline=true
# Use logging for default listeners [slf4j, sysout, file, custom]
decorator.datasource.p6spy.logging=file
# Log file to use (only with logging=file)
decorator.datasource.p6spy.log-file=spy.log
# Class file to use (only with logging=custom). The class must implement com.p6spy.engine.spy.appender.FormattedLogger
decorator.datasource.p6spy.custom-appender-class=my.custom.LoggerClass
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
decorator.datasource.p6spy.log-format=
# Use regex pattern to filter log messages. If specified only matched messages will be logged.
decorator.datasource.p6spy.log-filter.pattern=
# Report the effective sql string (with '?' replaced with real values) to tracing systems.
# NOTE this setting does not affect the logging message.
decorator.datasource.p6spy.tracing.include-parameter-values=true
Upvotes: 2
Views: 1343
Reputation: 1138
I was having the same issue as you and finally discovered how to fix that.
By default, p6spy excludes some categories from logging: info,debug,result,resultset,batch
,
through the spy.properties
config called excludecategories
.
The INSERTS, at least here, are part of the batch
category.
In my case I put in the spy.properties
file the line:
excludecategories=
and now it prints the INSERTS.
The documentation can be found in: https://p6spy.readthedocs.io/en/latest/configandusage.html
I couldn't find if this specific property is possible to be set in the application.properties
file. Looks like it is not supported by spring-boot-data-source-decorator
at the moment of this writing.
[]s
Upvotes: 0
Reputation: 564
Run it before p6spy configuration:
System.setProperty("p6spy.config.excludecategories", "info,debug,result")
Why it works? You probably have batched updates which are excluded from logging by default. This solution is kinda ugly, but configuration of excludecategories is currently not supported in spring-boot-data-source-decorator.
Upvotes: 0