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
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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With