Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable velocity logs

I've been trying to disable Velocity logs, and the only way I've found so far with positive results is to set:

runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem

but inside the velocity.properties that resides inside the velocity.jar.

I'm using velocity in a Web Application (tomcat) context. Is there any way to disable the velocity (by setting the previous property or whatever) BUT without modifying the JAR??

Cannot modify any CODE

Thanks in advance

like image 401
luiso1979 Avatar asked Oct 18 '13 06:10

luiso1979


2 Answers

In general: just add following line to your velocity.properties :

runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogChute

To your question: It depends on how the velocity engine is loaded. Is it possible to give it a custom velocity.properties file?
For example Solr's VelocityResponseWriter has such property called v.properties (or init.properties.file in current versions).
Look, if the method org.apache.velocity.app.VelocityEngine.init(Properties) is called somewhere in the code...

like image 190
dedek Avatar answered Oct 19 '22 01:10

dedek


This is how you can configure desired logging in velocity:

//java configuration
VelocityEngine ve = new VelocityEngine();
ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute" );
ve.setProperty("runtime.log.logsystem.log4j.logger","velocity");

//log4j properties
log4j.category.velocity=WARN

IMHO INFO is fine with velocity as on startup you will notice some useful velocity engine configuration details, but during templating nothing specific comes out from INFO level.

like image 6
harsh Avatar answered Oct 19 '22 03:10

harsh