| java.lang.Object org.zkoss.util.logging.Log
Log | public class Log (Code) | | The I3 logger. Usage:
private static final Log log = Log.lookup(MyClass.class);
...
if (log.debugable()) log.debug("the information to log:"+some);
Log is designed to minimize the memory usage by avoiding
unnecessary allocation of java.util.logging.Logger.
In additions, it is possible to use different logger, e.g., log4j,
without affecting the client codes.
Since this object is very light-weight, it is OK to have
the following statement without using it.
private static final Log log = Log.lookup(MyClass.class);
To log error or warning, simple use the error and warning method.
To log info, depending on the complexity you might want to test infoable
first.
log.info("a simple info");
if (log.infoable())
log.info(a + complex + string + operation);
To log debug information, we usually also test with D.
log.debug("a simple info");
if (D.ON && log.debugable())
log.debug(a + complex + string + operation);
There is a special level called FINER whose priority is lower than DEBUG.
It is generally used
to log massive debug message under certain situation. In other words,
it is suggested to use the debug methods to log messages as follows:
if (log.finerable()) {
... do massive testing and/or printing (use finer)
}
author: tomyeh |
Field Summary | |
final public static Level | ALL All levels. | final public static Level | DEBUG The DEBUG level. | final public static Level | ERROR The ERROR level. | final public static Level | FINER The FINER level. | final public static Level | INFO The INFO level. | final public static Level | OFF The OFF level used to turn of the logging. | final public static Level | WARNING The WARNING level. |
Constructor Summary | |
protected | Log(String name) The constructor. |
Method Summary | |
final public void | debug(String msg, Throwable t) Logs a debug message and a throwable object. | final public void | debug(String msg) Logs a debug message. | final public void | debug(Object obj, Throwable t) Logs an object, whose toString returns the debug message,
and a throwable object. | final public void | debug(Object obj) Logs an object, whose toString returns the debug message. | final public void | debug(Throwable t) Logs a debug throwable object. | final public void | debug(int code, Object[] fmtArgs, Throwable t) Logs a debug message and a throwable object by giving message code. | final public void | debug(int code, Object fmtArg, Throwable t) Logs a debug message and a throwable object by giving message code. | final public void | debug(int code, Throwable t) Logs a debug message and a throwable object by giving message code. | final public void | debug(int code, Object[] fmtArgs) Logs a debug message by giving message code. | final public void | debug(int code, Object fmtArg) Logs a debug message by giving message code. | final public void | debug(int code) Logs a debug message by giving message code. | final public boolean | debugable() Tests whether the
Log.DEBUG level is loggable. | final public void | eat(String message, Throwable ex) Logs an exception as an warning message about being eaten
(rather than thrown). | final public void | eat(Throwable ex) Logs an exception as an warning message about being eaten
(rather than thrown). | public boolean | equals(Object o) | final public void | error(String msg, Throwable t) Logs an error message and a throwable object. | final public void | error(String msg) Logs an error message. | final public void | error(Object obj, Throwable t) Logs an object, whose toString returns the error message,
and a throwable object. | final public void | error(Object obj) Logs an object, whose toString returns the error message. | final public void | error(Throwable t) Logs an error throwable object. | final public void | error(int code, Object[] fmtArgs, Throwable t) Logs an error message and a throwable object by giving message code. | final public void | error(int code, Object fmtArg, Throwable t) Logs an error message and a throwable object by giving message code. | final public void | error(int code, Throwable t) Logs an error message and a throwable object by giving message code. | final public void | error(int code, Object[] fmtArgs) Logs an error message by giving message code. | final public void | error(int code, Object fmtArg) Logs an error message by giving message code. | final public void | error(int code) Logs an error message by giving message code. | final public void | finer(String msg, Throwable t) Logs a finer message and a throwable object. | final public void | finer(String msg) Logs a finer message. | final public void | finer(Object obj, Throwable t) Logs an object, whose toString returns the finer message,
and a throwable object. | final public void | finer(Object obj) Logs an object, whose toString returns the finer message. | final public void | finer(Throwable t) Logs a finer throwable object. | final public void | finer(int code, Object[] fmtArgs, Throwable t) Logs a finer message and a throwable object by giving message code. | final public void | finer(int code, Object fmtArg, Throwable t) Logs a finer message and a throwable object by giving message code. | final public void | finer(int code, Throwable t) Logs a finer message and a throwable object by giving message code. | final public void | finer(int code, Object[] fmtArgs) Logs a finer message by giving message code. | final public void | finer(int code, Object fmtArg) Logs a finer message by giving message code. | final public void | finer(int code) Logs a finer message by giving message code. | final public boolean | finerable() Tests whether the
Log.FINER level is loggable. | final public Level | getLevel() Retruns the logging level. | final public static Level | getLevel(String level) Return the logging level of the specified string. | final public String | getName() Returns the name of this logger. | public int | hashCode() | final public void | info(String msg, Throwable t) Logs an info message and a throwable object. | final public void | info(String msg) Logs an info message. | final public void | info(Object obj, Throwable t) Logs an object, whose toString returns the info message,
and a throwable object. | final public void | info(Object obj) Logs an object, whose toString returns the info message. | final public void | info(Throwable t) Logs an info throwable object. | final public void | info(int code, Object[] fmtArgs, Throwable t) Logs an info message and a throwable object by giving message code. | final public void | info(int code, Object fmtArg, Throwable t) Logs an info message and a throwable object by giving message code. | final public void | info(int code, Throwable t) Logs an info message and a throwable object by giving message code. | final public void | info(int code, Object[] fmtArgs) Logs an info message by giving message code. | final public void | info(int code, Object fmtArg) Logs an info message by giving message code. | final public void | info(int code) Logs an info message by giving message code. | final public boolean | infoable() Tests whether the
Log.INFO level is loggable. | final public static boolean | isHierarchy() Returns whether the loggers support hierarchy.
If hierarchy is supported, a
Log instance is mapped to
a
Logger instance with the same name. | final public void | log(Level level, String msg, Throwable t) Logs a message and a throwable object at the giving level. | final public void | log(Level level, Object obj, Throwable t) Logs any object and a throwable object at the giving level. | final public void | log(Level level, int code, Object[] fmtArgs, Throwable t) Logs a message and a throwable object at the giving level
by giving a message code and multiple format arguments. | final public void | log(Level level, int code, Object fmtArg, Throwable t) Logs a message and a throwable object at the giving level
by giving a message code and ONE format argument. | final public void | log(Level level, int code, Throwable t) Logs a message and a throwable object at the giving level
by giving a message code and NO format argument. | final public static Log | lookup(Class cls) Gets the I3 logger based on the class. | final public static Log | lookup(String name) Gets the I3 logger based on the giving name. | final public static Log | lookup(Package pkg) Gets the I3 logger based on the package. | final public void | realCause(Throwable ex) Logs only the real cause of the specified exception. | final public void | realCause(String message, Throwable ex) Logs only the real cause of the specified exception with an extra
message as an error message. | final public void | realCauseBriefly(String message, Throwable ex) Logs only the first few lines of the real cause as an error message. | final public void | realCauseBriefly(Throwable ex) Lo only the first few lines of the real cause as an error message. | final public static void | setHierarchy(boolean hierarchy) Sets whether to support the hierarchical loggers. | final public void | setLevel(Level level) Sets the logging level. | public String | toString() | final public void | warning(String msg, Throwable t) Logs a warning message and a throwable object. | final public void | warning(String msg) Logs a warning message. | final public void | warning(Object obj, Throwable t) Logs an object, whose toString returns the warning message,
and a throwable object. | final public void | warning(Object obj) Logs an object, whose toString returns the warning message. | final public void | warning(Throwable t) Logs a warning throwable object. | final public void | warning(int code, Object[] fmtArgs, Throwable t) Logs a warning message and a throwable object by giving message code. | final public void | warning(int code, Object fmtArg, Throwable t) Logs a warning message and a throwable object by giving message code. | final public void | warning(int code, Throwable t) Logs a warning message and a throwable object by giving message code. | final public void | warning(int code, Object[] fmtArgs) Logs a warning message by giving message code. | final public void | warning(int code, Object fmtArg) Logs a warning message by giving message code. | final public void | warning(int code) Logs a warning message by giving message code. | final public void | warningBriefly(String message, Throwable ex) Logs only the first few lines of the real cause as an warning message. | final public void | warningBriefly(Throwable ex) Lo only the first few lines of the real cause. | final public boolean | warningable() Tests whether the
Log.WARNING level is loggable. |
DEBUG | final public static Level DEBUG(Code) | | The DEBUG level.
|
ERROR | final public static Level ERROR(Code) | | The ERROR level.
|
FINER | final public static Level FINER(Code) | | The FINER level.
|
INFO | final public static Level INFO(Code) | | The INFO level.
|
OFF | final public static Level OFF(Code) | | The OFF level used to turn of the logging.
|
WARNING | final public static Level WARNING(Code) | | The WARNING level.
|
debug | final public void debug(String msg, Throwable t)(Code) | | Logs a debug message and a throwable object.
Since debug messages are rarely disabled,
there is no method like infoable or debuggable.
|
debug | final public void debug(String msg)(Code) | | Logs a debug message.
|
debug | final public void debug(Object obj, Throwable t)(Code) | | Logs an object, whose toString returns the debug message,
and a throwable object.
Parameters: obj - the object whose toString method is called to get the message |
debug | final public void debug(Object obj)(Code) | | Logs an object, whose toString returns the debug message.
Parameters: obj - the object whose toString method is called to get the message |
debug | final public void debug(Throwable t)(Code) | | Logs a debug throwable object.
|
debug | final public void debug(int code, Object[] fmtArgs, Throwable t)(Code) | | Logs a debug message and a throwable object by giving message code.
|
debug | final public void debug(int code, Object fmtArg, Throwable t)(Code) | | Logs a debug message and a throwable object by giving message code.
|
debug | final public void debug(int code, Throwable t)(Code) | | Logs a debug message and a throwable object by giving message code.
|
debug | final public void debug(int code, Object[] fmtArgs)(Code) | | Logs a debug message by giving message code.
|
debug | final public void debug(int code, Object fmtArg)(Code) | | Logs a debug message by giving message code.
|
debug | final public void debug(int code)(Code) | | Logs a debug message by giving message code.
|
debugable | final public boolean debugable()(Code) | | Tests whether the
Log.DEBUG level is loggable.
|
eat | final public void eat(String message, Throwable ex)(Code) | | Logs an exception as an warning message about being eaten
(rather than thrown).
|
eat | final public void eat(Throwable ex)(Code) | | Logs an exception as an warning message about being eaten
(rather than thrown).
|
error | final public void error(String msg, Throwable t)(Code) | | Logs an error message and a throwable object.
Since error messages hardly happens and are rarely disabled,
there is no method like infoable or debuggable.
|
error | final public void error(String msg)(Code) | | Logs an error message.
|
error | final public void error(Object obj, Throwable t)(Code) | | Logs an object, whose toString returns the error message,
and a throwable object.
Parameters: obj - the object whose toString method is called to get the message |
error | final public void error(Object obj)(Code) | | Logs an object, whose toString returns the error message.
Parameters: obj - the object whose toString method is called to get the message |
error | final public void error(Throwable t)(Code) | | Logs an error throwable object.
|
error | final public void error(int code, Object[] fmtArgs, Throwable t)(Code) | | Logs an error message and a throwable object by giving message code.
|
error | final public void error(int code, Object fmtArg, Throwable t)(Code) | | Logs an error message and a throwable object by giving message code.
|
error | final public void error(int code, Throwable t)(Code) | | Logs an error message and a throwable object by giving message code.
|
error | final public void error(int code, Object[] fmtArgs)(Code) | | Logs an error message by giving message code.
|
error | final public void error(int code, Object fmtArg)(Code) | | Logs an error message by giving message code.
|
error | final public void error(int code)(Code) | | Logs an error message by giving message code.
|
finer | final public void finer(String msg)(Code) | | Logs a finer message.
|
finer | final public void finer(Object obj, Throwable t)(Code) | | Logs an object, whose toString returns the finer message,
and a throwable object.
Parameters: obj - the object whose toString method is called to get the message |
finer | final public void finer(Object obj)(Code) | | Logs an object, whose toString returns the finer message.
Parameters: obj - the object whose toString method is called to get the message |
finer | final public void finer(Throwable t)(Code) | | Logs a finer throwable object.
|
finer | final public void finer(int code, Object[] fmtArgs, Throwable t)(Code) | | Logs a finer message and a throwable object by giving message code.
|
finer | final public void finer(int code, Object fmtArg, Throwable t)(Code) | | Logs a finer message and a throwable object by giving message code.
|
finer | final public void finer(int code, Throwable t)(Code) | | Logs a finer message and a throwable object by giving message code.
|
finer | final public void finer(int code, Object[] fmtArgs)(Code) | | Logs a finer message by giving message code.
|
finer | final public void finer(int code, Object fmtArg)(Code) | | Logs a finer message by giving message code.
|
finer | final public void finer(int code)(Code) | | Logs a finer message by giving message code.
|
finerable | final public boolean finerable()(Code) | | Tests whether the
Log.FINER level is loggable.
|
getLevel | final public Level getLevel()(Code) | | Retruns the logging level.
|
getLevel | final public static Level getLevel(String level)(Code) | | Return the logging level of the specified string.
the level; null if no match at all |
getName | final public String getName()(Code) | | Returns the name of this logger.
|
hashCode | public int hashCode()(Code) | | |
info | final public void info(String msg, Throwable t)(Code) | | Logs an info message and a throwable object.
Since info messages are rarely disabled,
there is no method like infoable or debuggable.
|
info | final public void info(String msg)(Code) | | Logs an info message.
|
info | final public void info(Object obj, Throwable t)(Code) | | Logs an object, whose toString returns the info message,
and a throwable object.
Parameters: obj - the object whose toString method is called to get the message |
info | final public void info(Object obj)(Code) | | Logs an object, whose toString returns the info message.
Parameters: obj - the object whose toString method is called to get the message |
info | final public void info(Throwable t)(Code) | | Logs an info throwable object.
|
info | final public void info(int code, Object[] fmtArgs, Throwable t)(Code) | | Logs an info message and a throwable object by giving message code.
|
info | final public void info(int code, Object fmtArg, Throwable t)(Code) | | Logs an info message and a throwable object by giving message code.
|
info | final public void info(int code, Throwable t)(Code) | | Logs an info message and a throwable object by giving message code.
|
info | final public void info(int code, Object[] fmtArgs)(Code) | | Logs an info message by giving message code.
|
info | final public void info(int code, Object fmtArg)(Code) | | Logs an info message by giving message code.
|
info | final public void info(int code)(Code) | | Logs an info message by giving message code.
|
infoable | final public boolean infoable()(Code) | | Tests whether the
Log.INFO level is loggable.
|
isHierarchy | final public static boolean isHierarchy()(Code) | | Returns whether the loggers support hierarchy.
If hierarchy is supported, a
Log instance is mapped to
a
Logger instance with the same name. Therefore, it
forms the hierarchical relatiionship among
Logger instances.
It has the best resolution to control which logger to enable.
On the other hand, if the loggers don't support hierarchy,
all
Log instances are actually mapped to the same
Logger called "org.zkoss".
The performance is better in this mode.
Default: false.
Note: Once
LogService is initialized,
Log.setHierarchy is called automatically to turn on the hierarchy support.
|
log | final public void log(Level level, String msg, Throwable t)(Code) | | Logs a message and a throwable object at the giving level.
All log methods eventaully invokes this method to log messages.
Parameters: t - the throwable object; null to ignore |
log | final public void log(Level level, Object obj, Throwable t)(Code) | | Logs any object and a throwable object at the giving level.
Parameters: obj - the object whose toString method is called to get the message |
log | final public void log(Level level, int code, Object[] fmtArgs, Throwable t)(Code) | | Logs a message and a throwable object at the giving level
by giving a message code and multiple format arguments.
Parameters: t - the throwable object; null to ignore |
log | final public void log(Level level, int code, Object fmtArg, Throwable t)(Code) | | Logs a message and a throwable object at the giving level
by giving a message code and ONE format argument.
Parameters: t - the throwable object; null to ignore |
log | final public void log(Level level, int code, Throwable t)(Code) | | Logs a message and a throwable object at the giving level
by giving a message code and NO format argument.
Parameters: t - the throwable object; null to ignore |
lookup | final public static Log lookup(Class cls)(Code) | | Gets the I3 logger based on the class.
Parameters: cls - the class that identifies the logger. |
lookup | final public static Log lookup(String name)(Code) | | Gets the I3 logger based on the giving name.
|
lookup | final public static Log lookup(Package pkg)(Code) | | Gets the I3 logger based on the package.
|
realCause | final public void realCause(Throwable ex)(Code) | | Logs only the real cause of the specified exception.
It is useful because sometimes the stack trace is too big.
|
realCause | final public void realCause(String message, Throwable ex)(Code) | | Logs only the real cause of the specified exception with an extra
message as an error message.
|
realCauseBriefly | final public void realCauseBriefly(String message, Throwable ex)(Code) | | Logs only the first few lines of the real cause as an error message.
|
realCauseBriefly | final public void realCauseBriefly(Throwable ex)(Code) | | Lo only the first few lines of the real cause as an error message.
|
setHierarchy | final public static void setHierarchy(boolean hierarchy)(Code) | | Sets whether to support the hierarchical loggers.
|
setLevel | final public void setLevel(Level level)(Code) | | Sets the logging level.
|
warning | final public void warning(String msg, Throwable t)(Code) | | Logs a warning message and a throwable object.
Since warning messages are rarely disabled,
there is no method like infoable or debuggable.
|
warning | final public void warning(String msg)(Code) | | Logs a warning message.
|
warning | final public void warning(Object obj, Throwable t)(Code) | | Logs an object, whose toString returns the warning message,
and a throwable object.
Parameters: obj - the object whose toString method is called to get the message |
warning | final public void warning(Object obj)(Code) | | Logs an object, whose toString returns the warning message.
Parameters: obj - the object whose toString method is called to get the message |
warning | final public void warning(Throwable t)(Code) | | Logs a warning throwable object.
|
warning | final public void warning(int code, Object[] fmtArgs, Throwable t)(Code) | | Logs a warning message and a throwable object by giving message code.
|
warning | final public void warning(int code, Object fmtArg, Throwable t)(Code) | | Logs a warning message and a throwable object by giving message code.
|
warning | final public void warning(int code, Throwable t)(Code) | | Logs a warning message and a throwable object by giving message code.
|
warning | final public void warning(int code, Object[] fmtArgs)(Code) | | Logs a warning message by giving message code.
|
warning | final public void warning(int code, Object fmtArg)(Code) | | Logs a warning message by giving message code.
|
warning | final public void warning(int code)(Code) | | Logs a warning message by giving message code.
|
warningBriefly | final public void warningBriefly(String message, Throwable ex)(Code) | | Logs only the first few lines of the real cause as an warning message.
|
warningBriefly | final public void warningBriefly(Throwable ex)(Code) | | Lo only the first few lines of the real cause.
|
warningable | final public boolean warningable()(Code) | | Tests whether the
Log.WARNING level is loggable.
|
|
|