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

牧云@^-^@ 提交于 2019-12-08 07:27:17

问题


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?


回答1:


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).




回答2:


I believe Mojarra, being Sun code, uses java.util.logging.

The slf4j project download contains a drop-in module which forwards all j.u.l statements to slf4j. You can then use log4j as the slf4j backend.



来源:https://stackoverflow.com/questions/5125988/how-to-forward-jsf-ri-mojarra-log-to-slf4j-or-log4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!