Mantis - Resin
Viewing Issue Advanced Details
1186 minor always 06-07-06 07:35 06-13-06 11:04
ferg  
ferg  
normal  
closed  
fixed  
none    
none 3.0.20  
0001186: java.util.logging
(rep by MIchael Earl)

We are now discovering that for some reason ALL of our classes are creating log messages at ALL levels. This did not happen nor does it still happen with Tomcat -- with the same code. We love Resin by the way so this is not a complaint. I am seeking to understand why this is happening. I have added the following to our resin config file:

<logger name="com.hp.sfng" level="info" path='stdout:' timestamp='[%H:%M:%S.%s] '/>

This had no effect, all classes are sending log messages.

We have a LoggerManager class to wrap calls to Logger
 
public class LoggerManager
{
    static public Logger getLogger( Object object )
    {
        return getLogger( object.getClass().getName() );
    }
 
    static public Logger getLogger( String loggerName )
    {
        String METHOD = "getLogger";
        Logger logger = Logger.getLogger( loggerName );
        // Don't add the handlers if logging is disabled.
        if( isLoggingEnabled() )
        {
            // Add handlers to the logger
            if ( logger.getHandlers() == null || logger.getHandlers().length == 0 )
            {
                try
                {
                    if ( (loggingMode & MULTICAST_LOGGING) == MULTICAST_LOGGING )
                    {
                        logger.addHandler( new LogHandler() );
                    }
                    
                    if ( (loggingMode & STDERR_LOGGING) == STDERR_LOGGING )
                    {
                        logger.addHandler( new StderrHandler() );
                    }
                }
                catch ( Exception e )
                {
                    System.err.println( "Error adding LogHandler() to the logger: " + e.getMessage() );
                }
            }
            // WE do dot want to propogate any messages or the system logger will output to the console
            logger.setUseParentHandlers( false );
        }
        return logger;
    }
}
 
So we do something like this:
 
Logger logger = LoggerManager.getLogger( this );
 
This is essentially what you do below. However, we do not use the "shortcut" methods like logger.fine(), logger.finest() excepting entering() and exiting(). We always user logger.logp() or logger.entering(), logger,exiting().

Notes
(0001288)
ferg   
06-13-06 11:04   
server/024n

The new configuration will also help

  <logger name="com.hp.sfng" level="fine"/>