[jboss-jira] [JBoss JIRA] Created: (JBAS-4432) Log4J does not output JSF 1.2 implementation logging messages

Anastasios Georgousakis (JIRA) jira-events at lists.jboss.org
Mon May 21 05:16:53 EDT 2007


Log4J does not output JSF 1.2 implementation logging messages 
--------------------------------------------------------------

                 Key: JBAS-4432
                 URL: http://jira.jboss.com/jira/browse/JBAS-4432
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: JavaServerFaces
    Affects Versions: JBossAS-4.2.0.GA
            Reporter: Anastasios Georgousakis
         Assigned To: Stan Silvert


JSF uses java logging to output logging messages. JBoss include org.jboss.web.jsf.integration.config.JBossJSFConfigureListener to set a filter in java logging system in order logging messages to be handled from log4j. The problem is that setting only the filter is not enough because JSF implementation is checking if level is configured before calling a method to out put a message.

e.g 

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Converting buffered ServletOutputStream bytes" 
                            + " to chars using " + encoding);
            }

If you define in jboss-log4j.xml to enable logging for JSF implementation this will not have any effect and JSF messages will not be displayed. A workaround is to change the level of JSF logging if you find that specific levels are  enabled in log4j configuration.

I changed setLog4J in JBossJSFConfigureListener to set java logging levels for JSF logging categories with the following code.

    /**
     * If Log4J is being used, set a filter that converts JSF RI java.util.logger
     * messages to Log4J messages.
     */
    private void setLog4J() 
    {
        Filter conversionFilter = new Log4JConversionFilter(logConfigMessages());
        
        setLog4JFilter(Util.FACES_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.APPLICATION_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.CONFIG_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.CONTEXT_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.LIFECYCLE_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.RENDERKIT_LOGGER, conversionFilter);
        setLog4JFilter(Util.FACES_LOGGER + Util.TAGLIB_LOGGER, conversionFilter);
    }
    
    private void setLog4JFilter(String loggername, Filter conversionFilter) {
    	java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(loggername);
    	jdkLogger.setFilter(conversionFilter);
    	Logger jbossLogger = Logger.getLogger(loggername);
    	if(jbossLogger.isTraceEnabled())
    		jdkLogger.setLevel(Level.FINEST);
    	else if(jbossLogger.isDebugEnabled())
    		jdkLogger.setLevel(Level.FINE);
    	else if(jbossLogger.isInfoEnabled())
    		jdkLogger.setLevel(Level.INFO);
    }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list