Search code examples
javajsflog4jslf4jmojarra

How to forward JSF RI (Mojarra) log to slf4j or log4j?


How to teach Mojarra to use slf4j or log4j?

According to slf4j documentation I have to call:

org.slf4j.bridge.SLF4JBridgeHandler.install();

Somewhere in my project. But I can't call it in Mojarra... So, the question is when and how shall I execute this install() method?


Solution

  • The best way to do it is through a custom Listener. Being initialized before JSF servlet it should configure jul-to-slf4j bridge in contextInitialized(ServletContextEvent).