Problem
It may appear tricky to configure logging for solutions like Apache Commons Logging or Log4J, in Jaspersoft Studio (Professional).
Solution
Here below we will see some steps that allows us to configure different output files when using Apache Commons Logging and Log4J. We also specified to have detailed information (log level ALL) when logging is performed by one of the BigData connectors.
This is only one of the possible scenario. Different solutions can be taken, just modifying the JVM arguments passed or changing the configuration log files.
Locate the Jaspersoft Studio installation folder. For example: C:Program FilesJaspersoftJaspersoft Studio Professional-5.5.0.final
Edit the Jaspersoft Studio Professional.ini file and add the following arguments:
-Dlog4j.configuration=file:/C:/jsslog/config/log4j-config.properties-Dorg.apache.commons.logging.diagnostics.dest=C:/jsslog/outputs/commonsLoggingDiagOutput.log-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger-Djava.util.logging.config.file=C:/jsslog/config/logging-config.properties
- log4j.configuration specifies to use the dedicated file for loading Log4J configuration
- org.apache.commons.logging.diagnostics.dest specifies the output file for logging diagnostic messages of the Apache Commons Logging
- org.apache.commons.logging.Log specifies which Log implementation to use, in our case the one that wraps the standard JDK logging mechanisms
- java.util.logging.config.file specifies to use the dedicated file for loading the Java Logging API configuration
Create the log4j-config.properties as follow:
log4j.debug = truelog4j.appender.fileout = org.apache.log4j.RollingFileAppenderlog4j.appender.fileout.File = C:/jsslog/outputs/studioLOG4J.loglog4j.appender.fileout.MaxBackupIndex = 5log4j.appender.fileout.MaxFileSize = 8192KBlog4j.appender.fileout.layout = org.apache.log4j.PatternLayoutlog4j.appender.fileout.layout.conversionPattern = %d{ABSOLUTE} %5p %c{1},%t:%L - %m%nlog4j.rootLogger = DEBUG, fileout
Create the logging-config.properties as follow:
# File Handlerhandlers = java.util.logging.FileHandler# Set the default logging level for the root logger.level = INFO# log level for the connectorscom.jaspersoft.connectors.cassandra.level = ALLcom.jaspersoft.connectors.hive.level = ALLcom.jaspersoft.mongodb.level = ALL# Default formatterjava.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter# Specify the location and name of the log filejava.util.logging.FileHandler.pattern = C:/jsslog/outputs/studio-common.log
If you use Studio Preferences to set the logging properties (Preferences > Jaspersoft Studio > Global Settings), make sure you comment out the FileHandler.level or it will override the other levels set for packages / classes. This is because by default it is set later on in the config file:
# java.util.logging.FileHandler.level = INFO
Additional notes
- To debug queries generated by the report, try adding this to the logging-config.properties:
net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.level = FINE
You can also change the default level to off, if you want only your specific packages / classes to produce output in the log, for example:
.level = OFF
That will produce a cleaner log file.
- As for some other use case scenarios it can be useful to startup Jaspersoft Studio via command prompt in order to further investigate what is happening. For this reason you should locate the Jaspersoft Studio installation folder and rename the existing "eclipsec.exe" file to "Jaspersoft Studio Professionalc.exe".
- Then you can start the Jaspersoft Studio application using the command "Jaspersoft Studio Professionalc.exe" -consoleLog.
- Verify that you have permissions to read/write in the folder specified for config/output files.
- We did not use the Log4JLogger implementation in the org.apache.commons.logging.Log property because we verified issues similar to those described in here, with a similar error:
The log adapter 'org.apache.commons.logging.impl.Log4JLogger' is missing dependencies when loaded via classloader <....>
We need to further investigate the problem.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now