Is it possible to log generated SQL in Jasper Studio?

1

I've seen some discussion on how to log generated SQL on jasper server and iReport.  Is it possible to do so in Jaspersoft Studio?

jasperreportsuser's picture
Joined: Apr 3 2014 - 10:46am
Last seen: 4 years 1 week ago

2 Answers:

0

Java Util Logging (but not Log4j) should work as per Configuring Apache Commons Logging and Log4J in Jaspersoft Studio if you set this in log.properties:

net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.level = FINE

and comment out the default level for the FileHandler:

# java.util.logging.FileHandler.level = INFO

Also make sure java.util.logging.FileHandler.pattern

and -Dorg.apache.commons.logging.diagnostics.dest point to different files. The file set in java.util.logging.FileHandler.pattern should contain your SQL statements.

kkumlien's picture
2840
Joined: Jan 22 2015 - 4:36am
Last seen: 20 hours 7 sec ago
0

Good question.. normaly in JSS you write the query so it's pretty straight forward, what you write is sent to the DB, the only case you may find that useful is with marameter subtitution (if your query is using $P{} or $X{}) in that case you can use the JR query logging. 

To do this add "log4j.logger.net.sf.jasperreports.engine.query.JRJdbcQueryExecuter=debug" to your JSS jasperreports.properties file, check this thread http://community.jaspersoft.com/questions/526007/logging-sql-query-executed

marianol's picture
4778
Joined: Sep 13 2011 - 8:04am
Last seen: 1 year 1 month ago

Thank you for the reply. You are exactly right about the reasoning. I am trying to dig deeper into what is going on in my report and want to see what SQL results from my $X expressions. I believe your link is again referring to the Jasper Server. As I do not administrate the Jasper server I would like to view the SQL generated in Jaspersoft Studio. I searched the install folder for jasperreports.properties and it doesn't appear to be present. Any further suggestions?

jasperreportsuser - 5 years 4 months ago

Actually since that logger is in JasperReports it will be the same for JSS or JasperServer.
To change the jasperreports.properties file in JasperSoft Studio you have a UI to get there go to:
MyReports -> Properties -> Jaspersoft Studio group -> Properties -> Use Workspace Settings -> Configure Workspace Settings
and then you can add your log4j.logger.net.sf.jasperreports.engine.query.JRJdbcQueryExecuter=debug

But now that I look into it the log4J does not look like is configured by default in JSS so here is the info to configure it http://community.jaspersoft.com/wiki/configuring-apache-commons-logging-...

marianol - 5 years 4 months ago

I tried the configuration as defined http://community.jaspersoft.com/wiki/configuring-apache-commons-logging-... and added og4j.logger.net.sf.jasperreports.engine.query.JRJdbcQueryExecuter=debug as mentioned above however it still does not work. Can I get some help.

kaushik_3 - 3 years 3 weeks ago
Feedback
randomness