Velocity Logging

Overview

The Velocity log file contains errors, warnings, and information about the assembly of templates with the Velocity Assembler.  It can be used to troubleshoot problems with Templates.  In versions prior to 7.3.2 20180608 patch level  the Velocity log is located in the <InstallDir>/velocity.log file.  Later versions use Velocity 2.0 and the log file location has moved to the following locations:

Jetty

<InstallDir>/jetty/base/logs/velocity.log

Legacy JBOSS

<InstallDir>/AppServer/server/log/velocity.log

Browser Based Log Viewing

When troubleshooting templates it is often usefull to review the server.log and velocity.log files.  Both logs can be viewed from a Web Browser at the following urls on your Percussion server. 

Velocity Log:

http(s)://yourpercussion:yourport/Rhythmyx/test/velocitylog.jsp

Server Log:

http(s)://yourpercussion:yourport/Rhythmyx/test/logs.jsp

Log Configuration

The Velocity logging can be configured / tuned using the log4j.xml configuration file this file can be found in the following locations:

Jetty

/jetty/base/resources/log4.xml

Legacy Jboss

/AppServer/server/rx/conf/log4j.xml

The default configuration establishes a VelocityFile log appender. This file rotates after 10MB with a maximum of 10 log files stored after rotation.

<appender name="VelocityFile" class="org.apache.log4j.RollingFileAppender">
<errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
<param name="File" value="${jetty.base}/logs/velocity.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="TRACE"/>
<param name="MaxFileSize" value="10MB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>

The default logging appender is configured to log INFO level messages, which will include Informational, Errror, and Warning level log events. To enable Debug type logging changing the log level of this appender to DEBUG.

<logger name="org.apache.velocity">
<level value="INFO"/>
<appender-ref ref="VelocityFile"/>
</logger>

Note that when running Jetty, changes to the log4j.xml file will not take effect until the service is restarted. 

Logging from Velocity Templates

It is often useful to create log entries from within Velocity template code.  Note that logging from templates or macros currently gets written to the server.log (jetty/base/logs/server.log or AppServer/server/rx/log/server.log)

To write to the server.log from a template, the following line may be used. 

$rx.asmhelper.log(message, loglevel)##

Where loglevel is one of the following string values:

  • INFO
  • DEBUG
  • ERROR

Common Velocity Log Errors

Velocity 2.0 added some additional error logging to help Template developers troubleshoot logic problems in their templates. 

Left side of comparison has a null value

Example:

ERROR [org.apache.velocity.rendering] Left side ($sys.currentslot.relresults.size()) of comparison operation has null value at bSnMyNavSnippet[line 18, column 41]

This error indicates that there is a #if statement in the template on line 18, and the $sys.currentslot.relresults.size() parameter on the left hand size in null.  This would likely indicate that no slot is current when the #if statement is executed or that$sys.currentslot.relresults is null.  To fix this type of an error a additional null check could be added to the #if statement as the first condition to make sure that relresults and currentslot are not null.