Reputation: 818
I want to debug a few of my application JDBC queries so I wanted to configure java.util.logging to dump the actual SELECT statements that were run against the database and the data bound to their parameters.
I already have java.util.logging configured to log other messages to file. The setup code is as folloing:
Handler fh = new FileHandler("file.log", true);
Logger logger = Logger.getLogger("");
fh.setFormatter(new GruposLogFormatter());
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.info("==================================");
So, how can I configure java.util.logging to log JDBC queries to a file or sysout?
This answer barely touches the subject, but didn't help me.
Upvotes: 3
Views: 4537
Reputation: 8865
If you are using Hibernate following configurations can be done to get the sql queries printed.
How to print a query string with parameter values when using Hibernate
You can use http://sourceforge.net/projects/p6spy/ also and intercept all queries and log them to a file
Upvotes: 2