Jetspeed 2
  1. Jetspeed 2
  2. JS2-543

Velocity logging using the jetspeed-webapp-logging component



      By default, Velocity can already log message using Log4J if properly setup, but not through Commons Logging.
      For the Jetspeed portal application, most Velocity logging is already properly handled because the JetspeedVelocityServlet uses its own Velocity LogSystem implementation
      which uses a Commons Logging Log instance.
      But other VelocityEngines used from within Jetspeed (like the ones used for AJAX), as well as the engines used by the j2-admin, demo and rss web applications don't have
      this properly handled yet, with as result that all their logging information is current lost!

      The jetspeed-webapp-logging component provides a generic solution for properly logging from within a web application using both Commons Logging and Log4J.
      See: JS2-508 - Fixing commons-logging on WebSphere and other application servers.

      But, the jetspeed-webapp-logging solution requires that all logging is routed through Commons Logging and not directly through Log4J itself.
      So, I'm going to provide a custom Velocity LogSystem implementation, org.apache.jetspeed.webapp.logging.velocity.CommonsLoggingLog4JLogSystem, as part of the
      jetspeed-webapp-logging component.

      This CommonsLoggingLog4JLogSystem can be configured in file as follows:

      1. use Commons Logging for routing Velocity message through our IsolatedLog4JLogger
        runtime.log.logsystem.class =org.apache.jetspeed.webapp.logging.velocity.CommonsLoggingLog4JLogSystem
      2. Log4J Category used (default is "velocity")
        runtime.log.logsystem.log4j.category = velocity

      This is a standard solution provided by Velocity, for more information check:
      The configured log4j.category maps of course on a category defined in the, and has as default value "velocity".

      Note: some VelocityEngines used by Jetspeed are created through Spring with its org.springframework.ui.velocity.VelocityEngineFactoryBean.
      By default Spring will override a custom logging configuration provided through a (or defined inline) with their own CommonsLoggingLogSystem
      That works fine too, but it uses a hard coded category based on the VelocityEngine class name, causing the logging (in the case of the Jetspeed portal)
      to be written to the root logger (jetspeed.log).
      So, I'm gonna override this default Spring "logging override" by setting the "overrideLogging" property to false as I prefer all Velocity logging to be captured in our velocity.log file.

      Finally, as this solution is more generic, I'm gonna remove the custom JetspeedVelocityViewServlet logging handling and make use of the new CommonsLoggingLog4JLogSystem instead.

      Beware: after implementing this, I noticed lots of new Velocity error and warning messages logged which were "hidden" before

        Issue Links


          There are no comments yet on this issue.


            • Assignee:
              Ate Douma
              Ate Douma
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: