org.apache.jetspeed.webapp.logging.velocity
Class CommonsLoggingLog4JLogSystem

java.lang.Object
  extended by org.apache.jetspeed.webapp.logging.velocity.CommonsLoggingLog4JLogSystem
All Implemented Interfaces:
org.apache.velocity.runtime.log.LogSystem

public class CommonsLoggingLog4JLogSystem
extends Object
implements org.apache.velocity.runtime.log.LogSystem

Implementation of a LogSystem using Commons Logging to route Velocity message through a IsolatedLog4JLogger setup.

Configure the following in your velocity.properties:

For further information about setting up and configuring velocity: Velocity - Developer's Guide

If you want to use a VelocityEngine instantiated by Spring using its org.springframework.ui.velocity.VelocityEngineFactoryBean then you can also configure the above properties inline in its defintion or point it to your velocity.properties file.
But, beware of the following: the VelocityEngineFactoryBean by default overrides logging any configuration and hooks up their own CommonsLoggingLogSystem. Which works fine just as this one, but uses as (hard coded) logging category the VelocityEngine class name. So, if you do want to route your Velocity logging using your own category (or our default "velocity"), then you need to override the VelocityEngineFactoryBean default logging setup by setting its "overrideLogging" property to false.

Version:
$Id$
Author:
Ate Douma

Field Summary
static String DEFAULT_CATEGORY
           
private  org.apache.commons.logging.Log logger
           
 
Fields inherited from interface org.apache.velocity.runtime.log.LogSystem
DEBUG_ID, DEBUG_ON, ERROR_ID, INFO_ID, WARN_ID
 
Constructor Summary
CommonsLoggingLog4JLogSystem()
           
 
Method Summary
 void init(org.apache.velocity.runtime.RuntimeServices rs)
           
 void logVelocityMessage(int level, String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CATEGORY

public static final String DEFAULT_CATEGORY
See Also:
Constant Field Values

logger

private org.apache.commons.logging.Log logger
Constructor Detail

CommonsLoggingLog4JLogSystem

public CommonsLoggingLog4JLogSystem()
Method Detail

init

public void init(org.apache.velocity.runtime.RuntimeServices rs)
          throws Exception
Specified by:
init in interface org.apache.velocity.runtime.log.LogSystem
Throws:
Exception

logVelocityMessage

public void logVelocityMessage(int level,
                               String message)
Specified by:
logVelocityMessage in interface org.apache.velocity.runtime.log.LogSystem


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.