|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ireasoning.util.Logger
Logger implementation. It has six logging levels (from low to high) : DEBUG, INFO, WARN, ERROR, FATAL, NONE. NONE means logger is diabled. Logging level can be changed programmatically or read from logger's config file (Logger.prop). Logger can write to files or standard out depending on the settings in the config file.
This Logger is designed for speed and simplicity. If you think it does not have all the functionalities you want, you can call Logger.setUseLog4j(true), so it will swith to use log4j logger, which is a powerful open source logger implementation. Some of log4j's nice features include automatically rolling over files beyond the specified size, writing the logs to the NT Event Log System or syslog daemon. Log4j jar file is not included in our products, so you need to download log4j package and add its jar file to your classpath, and in your code, you need to add a few lines to set up log4j logger. This Logger's logging levels have the same meaning as log4j's corresponding ones.
If using log4j, Logger.prop will no longer be used. You need to configure the log4j logger or
provide a config file for it. You can still use the log methods in this Logger
to log messages,
then they will be delegated to corresponding methods in log4j logger.
A simple example of using log4j logger:
com.ireasoning.util.Logger.setUseLog4j(true); com.ireasoning.util.Logger.setLevel( com.ireasoning.util.Logger.ERROR );//set level to "ERROR" org.apache.log4j.BasicConfigurator.configure();//use the basic config of log4j
Field Summary | |
static String |
CONFIG_DIR
config file directory, ends with "/" |
static int |
DEBUG
The DEBUG priority designates fine-grained informational events that are most useful to debug an application |
static int |
ERROR
The ERROR priority designates error events that might still allow the application to continue running. |
static int |
FATAL
The FATAL priority designates very severe error events that will presumably lead the application to abort. |
static int |
INFO
The INFO priority designates informational messages that highlight the progress of the application. |
static boolean |
IS_EVAL
|
static String |
LOGGER_CONFIG_FILE
logger's config file name |
static int |
NONE
No logging at all |
static int |
WARN
The WARN priority designates potentially harmful situations. |
Method Summary | |
static void |
debug(Object msg)
Logs debug level message |
static void |
debug(Object this_ref,
String mesg)
Logs debug leve message |
static void |
debug(Object this_ref,
String name,
boolean value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(Object this_ref,
String name,
double value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(Object this_ref,
String name,
int value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(Object this_ref,
String name,
Object value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(Object msg,
Throwable e)
Log a message object with the DEBUG level including the stack trace of the Throwable e passed as parameter. |
static void |
debug(String name,
boolean value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(String name,
double value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(String name,
int value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(String name,
String value)
Logs debug level message, uses <name> = <value> format |
static void |
debug(Throwable e)
Logs the stack trace of the Throwable e passed as parameter with the DEBUG level. |
static void |
error(Object msg)
Log a message object with the ERROR Level. |
static void |
error(String msg,
Throwable e)
Log a message object with the ERROR level including the stack trace of the Throwable e passed as parameter, the same as error(Throwable e, String msg) |
static void |
error(Throwable e)
Logs the stack trace of the Throwable e passed as parameter with the ERROR level. |
static void |
error(Throwable e,
String msg)
Log a message object with the ERROR level including the stack trace of the Throwable e passed as parameter. |
static void |
fatal(Object msg)
Log a message object with the FATAL Level. |
static void |
fatal(Object msg,
Throwable e)
Log a message object with the FATAL level including the stack trace of the Throwable e passed as parameter. |
static String |
getLevel()
Returns the logging level as string format |
static int |
getLevelInt()
Returns the logging level as integer format, one of {Logger.DEBUG, Logger.INFO, Logger.WARN, Logger.ERROR, Logger.FATAL, Logger.NONE} |
static PrintStream |
getOutputStream(String level)
Returns the OutputStream for the passed logging level. |
static String |
getOutputStreamAsString(String level)
Returns the OutputStream for the passed logging level. |
static boolean |
getUseLog4j()
Returns the current value set by setUseLog4j, or false if no explicit setting has been made. |
static void |
hexDump(byte[] bytes)
Does hex dump with the DEBUG level. |
static void |
hexDump(byte[] bytes,
int start,
int end)
Does hex dump with the DEBUG level. |
static void |
info(Object msg)
Log a message object with the INFO Level. |
static void |
info(Object msg,
Throwable e)
Log a message object with the INFO level including the stack trace of the Throwable e passed as parameter. |
static void |
setAllOutputStreams(PrintStream stream)
Sets output stream for all logging levels |
static void |
setLevel(int level)
Sets new minimun logging level |
static void |
setLevel(String level)
Sets new minimun logging level |
static void |
setOutputStream(String level,
PrintStream stream)
Sets the OutputStream for the passed logging level. |
static void |
setOutputStream(String level,
String stream)
Sets the OutputStream for the passed logging level. |
static void |
setUseLog4j(boolean b)
Sets a flag indicating whether log4j logger should be used or not |
static void |
setUseSlf4j(boolean b)
Sets a flag indicating whether Slf4j logger should be used or not |
static void |
updateLoggerConfig()
Updates logger's config file |
static void |
warn(Object msg)
Log a message object with the WARN Level. |
static void |
warn(String msg,
Throwable e)
Log a message object with the WARN level including the stack trace of the Throwable e passed as parameter. |
static void |
warn(Throwable e)
Logs the stack trace of the Throwable e passed as parameter with the WARN level. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static boolean IS_EVAL
public static final String CONFIG_DIR
public static final String LOGGER_CONFIG_FILE
public static final int DEBUG
public static final int INFO
public static final int WARN
public static final int ERROR
public static final int FATAL
public static final int NONE
Method Detail |
public static void setUseLog4j(boolean b)
b
- if true, log4j logger will be used, false to use this logger(which is the default)public static void setUseSlf4j(boolean b)
b
- if true, log4j logger will be used, false to use this logger(which is the default)public static boolean getUseLog4j()
public static void setLevel(int level)
level
- one of {Logger.DEBUG, Logger.INFO, Logger.WARN, Logger.ERROR, Logger.FATAL, Logger.NONE}. NONE means no logging at allpublic static void setLevel(String level)
level
- one of {"DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"}, case insensitive. NONE means no logging at allpublic static String getLevel()
public static int getLevelInt()
public static void fatal(Object msg)
msg
- the message object to log.public static void fatal(Object msg, Throwable e)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void error(Object msg)
msg
- the message object to log.public static void error(Throwable e)
e
- the exception to log, including its stack trace.public static void error(String msg, Throwable e)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void error(Throwable e, String msg)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void hexDump(byte[] bytes)
public static void hexDump(byte[] bytes, int start, int end)
public static void debug(Object msg)
public static void debug(String name, String value)
public static void debug(String name, int value)
public static void debug(String name, boolean value)
public static void debug(String name, double value)
public static void debug(Object this_ref, String mesg)
this_ref
- this_ref.getClass().getName() will be written to loggermesg
- message to logpublic static void debug(Object this_ref, String name, Object value)
this_ref
- this_ref.getClass().getName() will be written to loggerpublic static void debug(Object this_ref, String name, int value)
this_ref
- this_ref.getClass().getName() will be written to loggerpublic static void debug(Object this_ref, String name, boolean value)
this_ref
- this_ref.getClass().getName() will be written to loggerpublic static void debug(Object this_ref, String name, double value)
this_ref
- this_ref.getClass().getName() will be written to loggerpublic static void debug(Throwable e)
e
- the exception to log, including its stack trace.public static void debug(Object msg, Throwable e)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void warn(String msg, Throwable e)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void warn(Throwable e)
e
- the exception to log, including its stack trace.public static void warn(Object msg)
msg
- the message object to log.public static void info(Object msg)
msg
- the message object to log.public static void info(Object msg, Throwable e)
msg
- the message object to log.e
- the exception to log, including its stack trace.public static void setOutputStream(String level, String stream)
level
- one of {DEBUG, INFO, WARN, ERROR, FATAL, NONE}, case insensitive.stream
- "stdout", "stderr" or file name (path can be included)public static void setAllOutputStreams(PrintStream stream)
public static PrintStream getOutputStream(String level)
level
- one of {DEBUG, INFO, WARN, ERROR, FATAL, NONE}, case insensitive.public static void setOutputStream(String level, PrintStream stream)
level
- one of {DEBUG, INFO, WARN, ERROR, FATAL, NONE}, case insensitive.stream
- output streampublic static String getOutputStreamAsString(String level)
level
- one of {DEBUG, INFO, WARN, ERROR, FATAL, NONE}, case insensitive.public static void updateLoggerConfig()
|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |