org.apache.jasper.logging
クラス Logger.Helper

java.lang.Object
  |
  +--org.apache.jasper.logging.Logger.Helper
すべての実装インタフェース:
LogAware
含まれているクラス:
Logger

public static class Logger.Helper
extends java.lang.Object
implements LogAware

Wrapper for Logger. It has a preferred log name to write to; if it can't find a log with that name, it outputs to the default sink. Also prepends a descriptive name to each message (usually the toString() of the calling object), so it's easier to identify the source.

Intended for use by client classes to make it easy to do reliable, consistent logging behavior, even if you don't necessarily have a context, or if you haven't registered any log files yet, or if you're in a non-Tomcat application. Not intended to supplant Logger, but to allow client objects a consistent bit of code that prepares log messages before they reach logger (and does the right thing if there is no logger).

Usage:

 class Foo {
   Logger.Helper loghelper = new Logger.Helper("tc_log", "Foo"); // or...
   Logger.Helper loghelper = new Logger.Helper("tc_log", this); // fills in "Foo" for you
   ...
     loghelper.log("Something happened");
     ...
     loghelper.log("Starting something", Logger.DEBUG);
     ...
     catch (IOException e) {
       loghelper.log("While doing something", e);
     }
 

作成者:
Alex Chaffee [alex@jguru.com]

コンストラクタの概要
protected Logger.Helper(java.lang.String logname)
          Subclass constructor, for classes that want to *be* a LogHelper, and get the log methods for free (like a mixin)
  Logger.Helper(java.lang.String logname, java.lang.Object owner)
           
  Logger.Helper(java.lang.String logname, java.lang.String prefix)
           
 
メソッドの概要
 Logger getLogger()
           
 Logger.Helper getLoggerHelper()
           
 void log(java.lang.String msg)
          Logs the message with level INFORMATION
 void log(java.lang.String msg, int level)
          Logs the message with given level
 void log(java.lang.String msg, java.lang.Throwable t)
          Logs the Throwable with level ERROR (assumes an exception is trouble; if it's not, use log(msg, t, level))
 void log(java.lang.String msg, java.lang.Throwable t, int level)
          Logs the message and Throwable to its logger or, if logger not found, to the default logger, which writes to the default sink, which is usually System.err
 void setLogger(Logger logger)
          Set a logger explicitly.
 void setLogname(java.lang.String logname)
          Set the logger by name.
 void setLogPrefix(java.lang.String prefix)
          Set the prefix string to be prepended to each message
 void setProxy(Logger.Helper helper)
          Set a "proxy" Logger.Helper -- whatever that one says its Logger is, use it
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Logger.Helper

protected Logger.Helper(java.lang.String logname)
Subclass constructor, for classes that want to *be* a LogHelper, and get the log methods for free (like a mixin)

Logger.Helper

public Logger.Helper(java.lang.String logname,
                     java.lang.Object owner)
パラメータ:
logname - name of log to use
owner - object whose class name to use as prefix

Logger.Helper

public Logger.Helper(java.lang.String logname,
                     java.lang.String prefix)
パラメータ:
logname - name of log to use
prefix - string to prepend to each message
メソッドの詳細

getLogger

public Logger getLogger()

setLogger

public void setLogger(Logger logger)
Set a logger explicitly. Also resets the logname property to match that of the given log.

(Note that setLogger(null) will not necessarily redirect log output to System.out; if there is a logger named logname it will fall back to using it, or trying to.)

定義:
インタフェース LogAware 内の setLogger

setLogname

public void setLogname(java.lang.String logname)
Set the logger by name. Will throw away current idea of what its logger is, and next time it's asked, will locate the global Logger object if the given name.

setLogPrefix

public void setLogPrefix(java.lang.String prefix)
Set the prefix string to be prepended to each message

setProxy

public void setProxy(Logger.Helper helper)
Set a "proxy" Logger.Helper -- whatever that one says its Logger is, use it

getLoggerHelper

public Logger.Helper getLoggerHelper()
定義:
インタフェース LogAware 内の getLoggerHelper

log

public void log(java.lang.String msg)
Logs the message with level INFORMATION

log

public void log(java.lang.String msg,
                java.lang.Throwable t)
Logs the Throwable with level ERROR (assumes an exception is trouble; if it's not, use log(msg, t, level))

log

public void log(java.lang.String msg,
                int level)
Logs the message with given level

log

public void log(java.lang.String msg,
                java.lang.Throwable t,
                int level)
Logs the message and Throwable to its logger or, if logger not found, to the default logger, which writes to the default sink, which is usually System.err


Copyright ? 2000 Apache Software Foundation. All Rights Reserved.