view SQL executed by Jasper report
Solution 1
JasperReports uses the Jakarta Commons Logging API. Commons Logging has a discovery mechanism that connects to logging API you are using in your project.
You need to configure logger named "net.sf.jasperreports" in your logging configuration file to control the logging level of JasperReports.
If you are using Log4j, you can read this section of there documentation for exact details.
For example you may write something like this in log4j.properties file
log4j.logger.net.sf.jasperreports=INFO, Daily
Where "Daily" is name of an appender configured in same properties file.
Solution 2
Another option is to use p6spy. P6Spy is sort of a "proxy JDBC driver" that sits between the app and the real JDBC driver, and it can log everything that it sees. You should be able to download a copy here: http://www.p6spy.com/
Solution 3
If you're using Ms SQL you can use sql profiler, to see every query executed on the server.
EDIT: Here is an article on enabling sql query logging on MySql server: http://www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/
Dónal
I earn a living by editing text files. I can be contacted at: [email protected] You can find out about all the different kinds of text files I've edited at: My StackOverflow Careers profile
Updated on July 05, 2022Comments
-
Dónal almost 2 years
When running a Jasper report in which the SQL is embedded in the report file (.jrxml), is it possible to see the SQL that is executed? Ideally, I'd also like to see the values that are substituted for each of the $P{} placeholders.
Cheers,
Don
-
Dónal over 15 yearsAny idea what settings would achieve that?
-
Dónal over 15 yearsI found instructions for enabling MySQL query logging on windows here: dotnot.org/blog/archives/2005/01/11/…
-
Kumar Gaurav Sharma over 5 yearsAs the link is dead! will you please elaborate log4j settings for same here.
-
Tahir Akhtar over 5 yearsThis seems like the new link commons.apache.org/proper/commons-logging/… But I didn't get a chance to verify