You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by gw...@apache.org on 2014/12/01 10:48:34 UTC

syncope git commit: [SYNCOPE-612] explicit configuration of Velocity logging

Repository: syncope
Updated Branches:
  refs/heads/1_2_X e414b79be -> f37a1bff9


[SYNCOPE-612] explicit configuration of Velocity logging


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/f37a1bff
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/f37a1bff
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/f37a1bff

Branch: refs/heads/1_2_X
Commit: f37a1bff945b373b4e7d0846a88073916fb9501a
Parents: e414b79
Author: Guido Wimmel <gw...@apache.org>
Authored: Mon Dec 1 10:47:02 2014 +0100
Committer: Guido Wimmel <gw...@apache.org>
Committed: Mon Dec 1 10:47:02 2014 +0100

----------------------------------------------------------------------
 .../core/util/VelocityEngineFactoryBean.java     | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/f37a1bff/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java b/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
index 105bf44..f98f073 100644
--- a/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
+++ b/core/src/main/java/org/apache/syncope/core/util/VelocityEngineFactoryBean.java
@@ -19,9 +19,11 @@
 package org.apache.syncope.core.util;
 
 import java.io.IOException;
+
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.CommonsLogLogChute;
 import org.springframework.beans.factory.FactoryBean;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.core.io.DefaultResourceLoader;
@@ -35,6 +37,8 @@ public class VelocityEngineFactoryBean implements FactoryBean<VelocityEngine>, I
 
     private ResourceLoader resourceLoader = new DefaultResourceLoader();
 
+	private boolean overrideLogging = true;
+    
     private VelocityEngine velocityEngine;
 
     public ResourceLoader getResourceLoader() {
@@ -45,7 +49,16 @@ public class VelocityEngineFactoryBean implements FactoryBean<VelocityEngine>, I
         this.resourceLoader = resourceLoader;
     }
 
-    private void createVelocityEngine() throws IOException, VelocityException {
+    public boolean isOverrideLogging() {
+		return overrideLogging;
+	}
+
+    /** Configure Velocity to use Commons Logging (true by default). */
+	public void setOverrideLogging(boolean overrideLogging) {
+		this.overrideLogging = overrideLogging;
+	}
+
+	private void createVelocityEngine() throws IOException, VelocityException {
         velocityEngine = new VelocityEngine();
 
         velocityEngine.setProperty(
@@ -57,6 +70,10 @@ public class VelocityEngineFactoryBean implements FactoryBean<VelocityEngine>, I
                 SpringVelocityResourceLoader.SPRING_RESOURCE_LOADER_CACHE, "true");
         velocityEngine.setApplicationAttribute(
                 SpringVelocityResourceLoader.SPRING_RESOURCE_LOADER, getResourceLoader());
+        
+		if (this.overrideLogging) {
+			velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute());
+		}
 
         velocityEngine.init();
     }