|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tomcat.util.log.Log
This is the main class seen by objects that need to log. It has a log channel 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.
Usage:
class Foo { Log log = Log.getLog("tc_log", "Foo"); // or... Log log = Log.getLog("tc_log", this); // fills in "Foo" for you ... log.log("Something happened"); ... log.log("Starting something", Log.DEBUG); ... catch (IOException e) { log.log("While doing something", e); }As a special feature ( required in tomcat operation ) the Log can be modified at run-time, by changing and configuring the logging implementation ( without requiring any special change in the user code ). That means that the user can do a Log.getLog() at any time, even before the logging system is fully configured. The embeding application can then set up or change the logging details, without any action from the log user.
Field Summary | |
static int |
DEBUG
|
static int |
ERROR
|
static int |
FATAL
Verbosity level codes. |
static int |
INFORMATION
|
protected java.lang.String |
logname
|
protected java.lang.String |
prefix
|
static int |
WARNING
|
Constructor Summary | |
protected |
Log(java.lang.String channel,
java.lang.String prefix,
LogHandler proxy,
java.lang.Object owner)
|
Method Summary | |
void |
close()
|
void |
flush()
Flush any buffers. |
java.lang.String |
getChannel(LogManager lm)
|
int |
getLevel()
The configured logging level for this channel |
static Log |
getLog(java.lang.String channel,
java.lang.Object owner)
|
static Log |
getLog(java.lang.String channel,
java.lang.String prefix)
|
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 prefix,
java.lang.String msg,
java.lang.Throwable t,
int 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 |
static LogManager |
setLogManager(LogManager lm)
Used by the embeding application ( tomcat ) to manage the logging. |
void |
setProxy(LogManager lm,
LogHandler l)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FATAL
public static final int ERROR
public static final int WARNING
public static final int INFORMATION
public static final int DEBUG
protected java.lang.String logname
protected java.lang.String prefix
Constructor Detail |
protected Log(java.lang.String channel, java.lang.String prefix, LogHandler proxy, java.lang.Object owner)
Method Detail |
public static Log getLog(java.lang.String channel, java.lang.String prefix)
public static Log getLog(java.lang.String channel, java.lang.Object owner)
public void log(java.lang.String msg)
public void log(java.lang.String msg, java.lang.Throwable t)
public void log(java.lang.String msg, int level)
public void log(java.lang.String msg, java.lang.Throwable t, int level)
public void log(java.lang.String prefix, java.lang.String msg, java.lang.Throwable t, int level)
public void flush()
public void close()
public int getLevel()
public static LogManager setLogManager(LogManager lm)
public java.lang.String getChannel(LogManager lm)
public void setProxy(LogManager lm, LogHandler l)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |