Logger (Jasper Internal API Documentation)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.jasper.logging.Logger
Interface for a logging object. A logging object provides mechanism for logging errors and messages that are of interest to someone who is trying to monitor the system.
Nested Class Summary | |
static class |
Logger.Helper
Wrapper for Logger. |
Field Summary | |
protected boolean |
custom
|
static int |
DEBUG
|
protected static Logger |
defaultLogger
|
protected static java.io.Writer |
defaultSink
|
static int |
ERROR
|
static int |
FATAL
Verbosity level codes. |
static int |
INFORMATION
|
protected static java.util.Hashtable |
loggers
|
protected java.lang.String |
name
|
protected java.io.Writer |
sink
|
protected boolean |
timestamp
Should we timestamp this log at all? |
protected java.lang.String |
timestampFormat
The timestamp format string, default is "yyyy-MM-dd hh:mm:ss" |
protected java.text.DateFormat |
timestampFormatter
|
protected boolean |
timestampRaw
true = The timestamp format is raw msec-since-epoch false = The timestamp format is a custom string to pass to SimpleDateFormat |
static int |
WARNING
|
Constructor Summary | |
Logger()
|
Method Summary | |
static boolean |
canIgnore(java.lang.Throwable t)
General purpose nasty hack to determine if an exception can be safely ignored -- specifically, if it's an IOException or SocketException that is thrown in the normal course of a socket closing halfway through a connection, or if it's a weird unknown type of exception. |
void |
close()
Close the log. |
abstract void |
flush()
Flush the log. |
protected java.lang.String |
formatTimestamp(long msec)
|
protected void |
formatTimestamp(long msec,
java.lang.StringBuffer buf)
|
static Logger |
getDefaultLogger()
Get the logger that prints to the default sink (usu. |
static Logger |
getLogger(java.lang.String name)
|
static java.util.Enumeration |
getLoggerNames()
|
java.lang.String |
getName()
Get name of this log channel. |
java.lang.String |
getPath()
|
java.lang.String |
getTimestampFormat()
|
int |
getVerbosityLevel()
Get the current verbosity level. |
boolean |
isOpen()
Is this Log usable? |
boolean |
isTimestamp()
|
void |
log(java.lang.String message)
Prints the log message at the "default" log level: INFORMATION |
void |
log(java.lang.String message,
int verbosityLevel)
Prints the log message. |
void |
log(java.lang.String message,
java.lang.Throwable t)
Prints log message and stack trace, with verbosityLevel ERROR. |
void |
log(java.lang.String message,
java.lang.Throwable t,
int verbosityLevel)
Prints log message and stack trace. |
boolean |
matchVerbosityLevel(int verbosityLevel)
|
void |
open()
Open the log - will create the log file and all the parent directories. |
static void |
putLogger(Logger logger)
|
protected abstract void |
realLog(java.lang.String message)
Subclasses implement these methods which are called by the log(..) methods internally. |
protected abstract void |
realLog(java.lang.String message,
java.lang.Throwable t)
Subclasses implement these methods which are called by the log(..) methods internally. |
static void |
removeLogger(Logger logger)
|
void |
setCustomOutput(java.lang.String value)
|
static void |
setDefaultSink(java.io.Writer w)
Set the default output stream that is used by all logging channels. |
void |
setName(java.lang.String name)
Set name of this log channel. |
void |
setPath(java.lang.String path)
Set the path name for the log output file. |
void |
setTimestamp(java.lang.String value)
Do we need to time stamp this or not? |
void |
setTimestampFormat(java.lang.String value)
If we are timestamping at all, what format to use when printing the timestamp. |
void |
setVerbosityLevel(int level)
Set the verbosity level for this logger. |
void |
setVerbosityLevel(java.lang.String level)
Set the verbosity level for this logger. |
static java.lang.String |
throwableToString(java.lang.Throwable t)
Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException if applicable TODO: JDBCException too |
static java.lang.String |
throwableToString(java.lang.Throwable t,
java.lang.String rootcause)
Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException or SQLException if applicable |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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 static java.io.Writer defaultSink
protected static java.util.Hashtable loggers
protected static Logger defaultLogger
protected boolean custom
protected java.io.Writer sink
protected java.lang.String name
protected boolean timestamp
protected boolean timestampRaw
protected java.lang.String timestampFormat
protected java.text.DateFormat timestampFormatter
Constructor Detail |
public Logger()
Method Detail |
public static void setDefaultSink(java.io.Writer w)
w
- the default output stream.public static Logger getLogger(java.lang.String name)
public static Logger getDefaultLogger()
public static java.util.Enumeration getLoggerNames()
public static void putLogger(Logger logger)
public static void removeLogger(Logger logger)
public static java.lang.String throwableToString(java.lang.Throwable t)
t
- any Throwable, or ServletException, or nullpublic static java.lang.String throwableToString(java.lang.Throwable t, java.lang.String rootcause)
t
- any Throwable, or ServletException, or nullrootcause
- localized string equivalent of "Root Cause"public static boolean canIgnore(java.lang.Throwable t)
public boolean isOpen()
public final void log(java.lang.String message)
message
- the message to log.public final void log(java.lang.String message, int verbosityLevel)
message
- the message to log.verbosityLevel
- what type of message is this?
(WARNING/DEBUG/INFO etc)public final void log(java.lang.String message, java.lang.Throwable t)
message
- the message to log.t
- the exception that was thrown.public final void log(java.lang.String message, java.lang.Throwable t, int verbosityLevel)
message
- the message to log.t
- the exception that was thrown.verbosityLevel
- what type of message is this?
(WARNING/DEBUG/INFO etc)public boolean matchVerbosityLevel(int verbosityLevel)
protected abstract void realLog(java.lang.String message)
message
- the message to log.protected abstract void realLog(java.lang.String message, java.lang.Throwable t)
message
- the message to log.t
- the exception that was thrown.public abstract void flush()
public void close()
public java.lang.String getName()
public void setName(java.lang.String name)
name
- Name of this logger.public void setPath(java.lang.String path)
path
- The path to the log file.public java.lang.String getPath()
public java.lang.String toString()
toString
in class java.lang.Object
public void open()
public void setVerbosityLevel(java.lang.String level)
level
- one of the verbosity level strings.public void setVerbosityLevel(int level)
level
- one of the verbosity level codes.public int getVerbosityLevel()
public void setTimestamp(java.lang.String value)
value
- "yes/no" or "true/false"public boolean isTimestamp()
public void setTimestampFormat(java.lang.String value)
SimpleDateFormat
public java.lang.String getTimestampFormat()
public void setCustomOutput(java.lang.String value)
protected java.lang.String formatTimestamp(long msec)
protected void formatTimestamp(long msec, java.lang.StringBuffer buf)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |