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
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.
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/
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/
You can adjust your log4j settings to log the running SQL...
Related
I want to print a particular hibernate query in UAT environment. However, I do not want to enable hibernate logging for all the queries since it will start generating huge logs.
Is there a way I can enable hibernate query logging through java code just before the query I want to print and then disable it immediately? Please note that I am using Spring data Jpa repository.
It depends on the logging library that you use.
I think Spring uses SLF4J and logback so something like the following should work:
LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory();
loggerContext.getLogger("org.hibernate.SQL").setLevel(Level.DEBUG);
and afterwards set
loggerContext.getLogger("org.hibernate.SQL").setLevel(Level.ERROR);
There is away to do customized logging with help of logback but not sure it will help to log the particular SQL logs.
Use this link -https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.logging
I have Java project deployed to JBoss EAP 6.4 using Liquibase to upgrade the database on deployment. However all the Liquibase INFO logging is being sent to the stderr log. So it looks like errors.
Is there a way to configure the default logging stream?
Yes, there is. The beast way (in my opinion) is to replace the built-in logging with the liquibase-slf4j logging interface. There are more details on how to do that in this question/answer and other answers linked here:
How to get liquibase to log using slf4j?
I'm used to using log4j and whenever there were setup/config problems I'd enable "-Dlog4j.debug" and all the config info would be dumped out at startup.
This was very useful on a number of occasions.
Now I'm working on a Spring boot application, which I've found uses:
Commons logging Logger statements in the client code
A bridge jar (jcl-over-slf4j-xxx.jar) which translates the commons logging calls into slf4j more info here
Finally slf4j uses "logback" as the underlying logging framework
I found it rather painful to figure all this out.
Is there an equivalent of -Dlog4j.debug which can show me how this is all hanging together at startup time?
This is the best/only option I've found so far, and it's logback specific.
Use this -D on the command line:
-Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener
Taken from here
This essentially is the logback equivalent of log4j's -Dlog4j.debug.
It dumps the logback startup sequence to the console at startup time, as the logging system is initialised.
This is not a true answer as I'd like some messages to show before this to show why logback is being used, but I haven't found anything like that yet.
Aside: This may also be useful for Spring Boot:
-Ddebug
Taken from here and here
If you are using logback, I assume you are using the logback.xml file? Then if you start that file with <configuration debug="true"> then it should dump the status information. More information in the documentation under status data section.
I use HSQLDB on OSGI framework. And it is common solution to use pax-logging that support many logging frameworks (java logging, slf4j, jboss logging etc).
I don't have problems with pax-logging, however, I have problems with HSQLDB logging messages. HSQLDB logging component is very tricky - some messages go to pax-logging system, some go to console.
Could anyone explain what messages where must go and why.
There are separate logging components in HSQLDB.
The Server uses separate writers for log and error messages. The logs default to stdout and stderr but you can set each one to use a custom PrintWriter.
The optional SQL log is always a file. It can be turned on and off live for checking the SQL statements being executed.
The optional event log is a file or an external logging framework. The latter is used when the database is in-process in an application. In both configurations, it reports general persistence events at different levels of detail selected by the user.
I am running a web-app on apache tomcat that grabs data from the web and then writes into an excel sheet. I am getting several warnings on the tomcat stdout that is making the whole look of the workflow ugly.
How can I suppress the warnings of the apache tomcat stdout?
Have a look at How to set level logging to DEBUG in Tomcat? or the tomcat documentation on Logging: http://tomcat.apache.org/tomcat-6.0-doc/logging.html
You essentially want to scale the logging down to just (critical) errors.
Dw
Given that Tomcat doesn't write directly to STDOUT, I assume that some library you are using does. You can re-direct this output using the swallowOutput attribute of the Context.