← Back to team overview

dhis2-devs team mailing list archive

Re: Velocity log

 

I tried out a few things, and it seems to be related to the init of
velocity.

The initial errors related to the velocity.log can be relieved with the
following diff, although I never actually see this file appear anywhere.
These errors occur before the initial start-up procedures commence.

There is a second round of errors which occur, after the server startup,
which I cannot get rid of.

which can be seen here  http://pastebin.com/bRjmw5uh

This seems to be another problem, possibly related to some other
VelocityManager not being inited properly .

This is a relatively minor issue, but we should solve it to prevent all of
this crap from appearing unnecessarily in production logs.

Regards,
Jason



=== modified file
'dhis-2/dhis-support/dhis-support-system/src/main/java/org/his
p/dhis/system/velocity/VelocityManager.java'
---
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/v
elocity/VelocityManager.java    2011-10-07 10:08:02 +0000
+++
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/v
elocity/VelocityManager.java    2011-10-29 15:03:16 +0000
@@ -33,6 +33,10 @@
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.BasicConfigurator;

 public class VelocityManager
 {
@@ -42,20 +46,34 @@
     private static final String VM_SUFFIX = ".vm";
     private VelocityEngine velocity;

+    public static String LOGGER_NAME = "dhis2-velocity.log";
+
+
     public VelocityManager() throws Exception
     {
+        //Maybe we should just nuke this log completely?
+        //java.util.Properties p = new java.util.Properties();
+       // p.setProperty("runtime.log.logsystem.class",
"org.apache.velocity.run
time.log.NullLogSystem");
+
+        BasicConfigurator.configure();
+        Logger log = Logger.getLogger ( LOGGER_NAME );
+        log.info("Starting velocity log");
+
         velocity = new VelocityEngine();
         velocity.setProperty( Velocity.RESOURCE_LOADER,
RESOURCE_LOADER_NAME );

         velocity.setProperty( RESOURCE_LOADER_NAME +
".resource.loader.class",
ClasspathResourceLoader.class.getName() );
+        velocity.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"or
g.apache.velocity.runtime.log.Log4JLogChute" );
+
velocity.setProperty("runtime.log.logsystem.log4j.logger",LOGGER_NAME);

         velocity.init();
-    }
+        log.info("follows initialization output from velocity");
+        }
+
+

     public String render( Object object, String template )
     {
         try
         {
             StringWriter writer = new StringWriter();
-
             VelocityContext context = new VelocityContext();

             if ( object != null )

Follow ups

References