Jump to content
  • Configuring Apache Commons Logging and Log4J in Jaspersoft Studio

    • Features: Logging Audience: Developer Skill: Intermediate


    It may appear tricky to configure logging for solutions like Apache Commons Logging or Log4J, in Jaspersoft Studio (Professional).


    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. 

    1. Locate the Jaspersoft Studio installation folder. For example: C:Program FilesJaspersoftJaspersoft Studio Professional-5.5.0.final

    2. Edit the Jaspersoft Studio Professional.ini file and add the following arguments:


      • 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
    3. 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

    4. 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

    5. 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. 

    Related articles

    User Feedback

    Recommended Comments

    I believe Log4j (as opposed to Commons Logging) works only if a class uses it explicitly?

    For example net.sf.jasperreports.engine.query.JRJdbcQueryExecuter does not work in debug in log4j-config.properties, but it worked for me when set in log.properties:


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


    Btw it only works if I comment out the FileHandler level, otherwise it stays everything at INFO level instead of FINE:


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

    Link to comment
    Share on other sites

    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 account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...