FileDocCategorySizeDatePackage
IASLogger.javaAPI DocGlassfish v2 API4856Fri May 04 22:35:30 BST 2007com.sun.enterprise.web.logger

IASLogger

public final class IASLogger extends LoggerBase
An implementation of Logger that writes log messages using JDK 1.4's logging API.
author
Arvind Srinivasan
author
Neelam Vaidya
version
$Revision: 1.5 $

Fields Summary
Logger
_logger
The server wide log message handler.
private String
_classname
Classname of the object invoking the log method.
private String
_methodname
Name of the method invoking the log method.
protected static final String
info
The descriptive information about this implementation.
Constructors Summary
private IASLogger()
Deny void construction.



    // ----------------------------------------------------------- Constructors

            
      
        super();
    
public IASLogger(Logger logger)
Construct a new instance of this class, that uses the specified logger instance.

param
logger The logger to send log messages to

        _logger = logger;
    
Methods Summary
private voidinferCaller()
Examine the call stack and determine the name of the method and the name of the class logging the message.

        // Get the stack trace.
        StackTraceElement stack[] = (new Throwable()).getStackTrace();
        _classname = "";
        _methodname = "";
        for (int ix=0; ix < stack.length; ix++) {
	    StackTraceElement frame = stack[ix];
	    _classname = frame.getClassName();
	    if (!_classname.startsWith("com.sun.enterprise.web.logger")) {
		// We've found the relevant frame. Get Method Name.
		_methodname = frame.getMethodName();
		return;
	    }
        }
    
protected voidwrite(java.lang.String msg, int verbosity)
Logs the message to the JDK 1.4 logger that handles all log messages for the iPlanet Application Server.


        if (_logger == null)
            return;

        Level level = Level.INFO;

        if (verbosity == FATAL)
            level = (Level)IASLevel.FATAL;
        else if (verbosity == ERROR)
            level = Level.SEVERE;
        else if (verbosity == WARNING)
            level = Level.WARNING;
        else if (verbosity == INFORMATION)
            level = Level.INFO;
        else if (verbosity == DEBUG)
            level = Level.FINER;

        inferCaller();
        _logger.logp(level, _classname, _methodname, msg);