RE: Issues with java.util.logging
"Earl, Michael" <[email protected]> Tue, 6 Jun 2006 18:33:56 -0700
| Newsgroups | gmane.text.xml.resin.user |
|---|---|
| Message-ID | <96ECC502D2678A4192F48386A524718D04E2B57D@cacexc07.americas.cpqcorp.net> |
HI Scott,
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().
Thanks for any suggestions,
Mike.
________________________________
From: [email protected]
[mailto:[email protected]] On Behalf Of Scott Ferguson
Sent: Tuesday, June 06, 2006 4:00 PM
To: [email protected]
Subject: Re: Issues with java.util.logging
On Jun 6, 2006, at 2:54 PM, Earl, Michael wrote:
Hello All,
We recently migrated from Tomcat to Resin. 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.
Can you give a sample of how you're allocating and using the Logger?
Our standard pattern is:
package com.caucho.foo;
public class Bar {
private static final Logger log =
Logger.getLogger(Bar.class.getName());
Then we use
log.info - stuff users should see
log.finer - stuff application writers will want to see to help
debugging
log.finest - more details for us to debug, but which may be cryptic to
outside developers
-- Scott
Thanks for any help,
Mike.
---------------------------------------------------
Michael Earl "For whoever exalts
Software Engineer himself will be humbled,
GO-IT MBP/SF and whoever humbles
Bldg R4 himself will be exalted."
HP, Roseville CA
+1-916-748-7958 work Matthew 23:12
+1-916-671-4466 cell
---------------------------------------------------