title: JSF2 logs with tomcat
body: <p>I'm having a project using JSF2 (2.1.2), Richfaces4 (4.0.0.Final) on tomcat6 (6.0.28). In order to manage portability between Tomcat and WebSphere7 for my EARs, I have the following jars inside my tomcat lib: el-api-2.2.jar, jsf-api-2.1.2.jar, jsf-impl-2.1.2.jar, validation-api-1.0.0.GA.jar.</p>
  
  <p>My problem is that I never managed to change the log levels of JSF or Richfaces and except from the initialization ones, I don't see any inside my console. Even when I get exceptions in my server response !</p>
  
  <p>I tried several ways:</p>
  
  <p>1) Inside my applications, I'm using slf4j and log4j. So the natural way would be to use SLF4JBridgeHandler.install(). I made a small servlet to call this method during its init() method and added a 'load-on-startup' to be sure it's loaded before JSF Servlet (I'm not sure tomcat cares at all about this load-on-startup directive because I still get logs from JSF init before), e.g.:</p>
  
  <pre><code>INFO: JSF1027 : [null] Les objets ELResolvers de JSF n’ont pas été enregistrés avec le conteneur JSP.
  09-09-2011 16:50:58:591 [Thread-2] 937  DEBUG com.jsf.test.SLF4JBridgeHandlerInstallerServlet - SLF4JBridgeHandler.install() OK!
  </code></pre>
  
  <p>I also added some configuration in my log4j.xml:</p>
  
  <pre><code>&lt;logger name="javax.faces"&gt;&lt;level value="debug"/&gt;&lt;/logger&gt;  
  &lt;logger name="com.sun.faces"&gt;&lt;level value="debug"/&gt;&lt;/logger&gt;
  &lt;logger name="javax.enterprise.resource.webcontainer.jsf"&gt;&lt;level value="debug"/&gt;&lt;/logger&gt;
  </code></pre>
  
  <p>But I don't see any logs in my console when displaying a JSF page...
  I also tried using a filter to call SLF4JBridgeHandler.install() before the execution of the JSF Servlet, but I only get a lot of OK logs from my filter...</p>
  
  <p>2) I tried to follow the tutorial <a href="http://java-tutorial.ch/java-server-faces/jsf-2-logging-with-tomcat" rel="noreferrer">here</a> exactly (it creates new files in tomcat log folder for each logger of JSF2). I tried by changing the logging.properties inside the conf folder of tomcat and by adding a new logging.properties inside my src/resources/ folder in my application. But no luck...</p>
  
  <p>3) I tried to add the JSF loggers to the the logging.properties inside my tomcat by adding this:</p>
  
  <pre><code>javax.enterprise.resource.webcontainer.jsf.managedbean.level=FINEST
  javax.enterprise.resource.webcontainer.jsf.managedbean.handlers = java.util.logging.ConsoleHandler
  javax.enterprise.resource.webcontainer.jsf.config.level=FINEST
  javax.enterprise.resource.webcontainer.jsf.config.handlers = java.util.logging.ConsoleHandler
  javax.enterprise.resource.webcontainer.jsf.facelets.level=FINEST
  javax.enterprise.resource.webcontainer.jsf.facelets.handlers = java.util.logging.ConsoleHandler
  javax.enterprise.resource.webcontainer.jsf.resource.level=FINEST
  javax.enterprise.resource.webcontainer.jsf.resource.handlers = java.util.logging.ConsoleHandler
  javax.enterprise.resource.webcontainer.jsf.lifecycle.level=FINEST
  javax.enterprise.resource.webcontainer.jsf.lifecycle.handlers = java.util.logging.ConsoleHandler
  </code></pre>
  
  <p>No luck yet...</p>
  
  <p>4) I tried to use log4j inside tomcat instead of juli by following <a href="http://mrhaki.blogspot.com/2011/02/configure-log4j-on-tomcat.html" rel="noreferrer">this documentation</a>. It seems to work well, but changing the resulting log4j.properties to put the JSF loggers in DEBUG didn't work...</p>
  
  <p>Any idea ?</p>
  
  <p>Regards,</p>
  
  <p>Florian</p>