title: How to Disable velocity debug and INFO log messages in my Jetty / log4j environment?
body: <p>I am getting lots of velocity debug and INFO messages showing up in my Jetty console. I would like to turn off info and debug messages that velocity spits out. </p>
  
  <p>Environment:</p>
  
  <ul>
  <li>I have a velocity properties file.</li>
  <li>I have a log4j.xml file </li>
  <li>I have a classpath which may error on the side of having more classes than one would expect like LogKitLogger which comes from commons-logging so it may not matter since it is not Logkit. Logkit is mentioned in the <a href="http://velocity.apache.org/engine/devel/developer-guide.html#Configuring_Logging" rel="nofollow noreferrer">Velocity Configuring_Logging page</a></li>
  </ul>
  
  <p><strong>This is a sample message</strong></p>
  
  <pre><code>2011-04-03 13:00:14.627:/myproject:INFO:   Velocity  [debug] ResourceManager : found /com/somecompany/something/somefile_ok.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
  </code></pre>
  
  <p>It seems like the following below needs to happen in order to turn off velocity messages that we do not want to see now. We also want to make it easy to turn velocity messages back on when we need them:</p>
  
  <ol>
  <li>hook up velocity with log4j</li>
  <li>specify that we only want to see ERROR and above.</li>
  </ol>
  
  <p>Things I read:</p>
  
  <ul>
  <li><p>The Stackoverflow <a href="https://stackoverflow.com/questions/4738705/change-velocity-logging-to-console">Spit Velocity Out To Console</a> post looked promising. However, the more I looked at the log4j.xml and compared it with the jetty configuration, the more it seems like the messages I am seeing are coming through jetty.</p></li>
  <li><p>I have also read the <a href="http://velocity.apache.org/engine/devel/developer-guide.html#Configuring_Logging" rel="nofollow noreferrer">Velocity Configuring_Logging page</a></p></li>
  </ul>
  
  <p>Before I do any more <a href="http://en.wiktionary.org/wiki/yak_shaving" rel="nofollow noreferrer">Yak Shaving</a> on this, I wanted to make sure I am on track with the approach outlined above</p>
  
  <p>By the way, we're using Spring 3.x</p>
  
  <p>Thanks for any help you can offer on this. :)</p>
  
  <p>As suggested, here is the log4j.xml with minor tweaks to names:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
     &lt;!-- ===================================================================== --&gt;
     &lt;!--                                                                       --&gt;
     &lt;!--  Log4j Configuration                                                  --&gt;
     &lt;!--                                                                       --&gt;
     &lt;!-- ===================================================================== --&gt;
     &lt;!-- $Id: log4j.xml,v 1.6 2011-04-07 16:39:50 consumergear Exp $ --&gt;
     &lt;!--
     | For more configuration infromation and examples see the Jakarta Log4j
     | owebsite: http://jakarta.apache.org/log4j
  
     DEVELOPMENT CONFIGURATION
  
   --&gt;
  &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"&gt;
  
     &lt;!-- ================================= --&gt;
     &lt;!-- Preserve messages in a local file --&gt;
     &lt;!-- ================================= --&gt;
  
     &lt;appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"&gt;
        &lt;param name="Threshold" value="WARN" /&gt;
        &lt;param name="file" value="G:/logs/somewebplatform/somewebapp-webapp_log4j.log" /&gt;
        &lt;param name="append" value="true" /&gt;
        &lt;layout class="org.apache.log4j.PatternLayout"&gt;
           &lt;param name="ConversionPattern" value="%d{ISO8601} %5p %c:%L - %m%n" /&gt;
        &lt;/layout&gt;
     &lt;/appender&gt;
  
     &lt;!-- ============================== --&gt;
     &lt;!-- Append messages to the console --&gt;
     &lt;!-- ============================== --&gt;
     &lt;appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"&gt;
        &lt;param name="Target" value="System.out" /&gt;
        &lt;param name="Threshold" value="FATAL" /&gt;
        &lt;layout class="org.apache.log4j.PatternLayout"&gt;
           &lt;!-- The default pattern: Date Priority [Category] Message\n --&gt;
           &lt;param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n" /&gt;
        &lt;/layout&gt;
     &lt;/appender&gt;
  
     &lt;!-- Hide those pesky Hibernate logs. --&gt;
     &lt;logger name="net.sf"&gt;
        &lt;level value="ERROR" /&gt;
     &lt;/logger&gt;
  
     &lt;!-- Hide those pesky apache commons logs. --&gt;
     &lt;logger name="org.apache.commons"&gt;
        &lt;level value="ERROR" /&gt;
     &lt;/logger&gt;
  
     &lt;logger name="com.yesorganization"&gt;
        &lt;level value="WARN" /&gt;
        &lt;appender-ref ref="FILE" /&gt;
     &lt;/logger&gt;
  
     &lt;!-- ======================= --&gt;
     &lt;!-- Setup the Root category --&gt;
     &lt;!-- ======================= --&gt;
     &lt;root&gt;
        &lt;priority value="WARN" /&gt;
        &lt;appender-ref ref="CONSOLE" /&gt;
        &lt;appender-ref ref="FILE" /&gt;
     &lt;/root&gt;
  
  &lt;/log4j:configuration&gt;
  </code></pre>
  
  <p>the velocity properties with minor name tweaks</p>
  
  <pre><code>#
  # specify two resource loaders to use
  #
  resource.loader = file, class
  #
  ##
  ## for the loader we call 'file', set the FileResourceLoader as the
  ## class to use, turn off caching, and use 3 directories for templates
  ##
  file.resource.loader.description = Velocity File Resource Loader
  file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
  file.resource.loader.path = d:/projects/somewebapp-webapp/src
  file.resource.loader.cache = false
  file.resource.loader.modificationCheckInterval = 0
  #C:/Projectsyaya/someorg/src/core/java
  ##
  ##  for the loader we call 'class', use the ClasspathResourceLoader
  ##
  class.resource.loader.description = Velocity Classpath Resource Loader
  class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
  # 
  
  #jar.resource.loader.path = jar:file:/myjarplace/myjar.jar
  #jar.resource.loader.path = jar:file:/WEB-INF/lib/someorg-something-1.116.jar
  </code></pre>