org.knime.core.node
Class NodeLogger

java.lang.Object
  extended by org.knime.core.node.NodeLogger

public final class NodeLogger
extends Object

The general logger used to write info, warnings, errors , debugging, assert messages, exceptions, and coding problems into the internal Log4J logger. The loggers are configured by the log4j.properties file in the root of the core package. The configuration can be overridden by specifying a file in -Dlog4j.configuration (this is the standard log4j behaviour). Furthermore, it is possible to add and remove additional writers to this logger. Note, calling setLevelIntern(LEVEL) does only effect the minimum logging level of the default loggers. All other writers' levels have to be set before hand.

Author:
Thomas Gabriel, University of Konstanz

Nested Class Summary
static class NodeLogger.LEVEL
          The logging levels.
 
Field Summary
static String LOG_FILE
          The default log file name, knime.log.
 
Method Summary
static void addWriter(Writer writer, NodeLogger.LEVEL minLevel, NodeLogger.LEVEL maxLevel)
          Adds a new Writer with the given level to this logger.
 void assertLog(boolean b, String m)
          Check assert and write into logger if failed.
 void assertLog(boolean b, String m, AssertionError e)
          Check assertions on/off and write debug message into logger.
 void coding(Object o)
          Writes CODING PROBLEM plus this message into this logger as error.
 void coding(Object o, Throwable t)
          Writes CODING PROBLEM plus this message, as well as the the message of the throwable into this logger as error and debug.
 void debug(Object o)
          Write debugging message into this logger.
 void debug(Object o, Throwable t)
          Write debugging message and throwable into this logger.
 void error(Object o)
          Write error message into the logger.
 void error(Object o, Throwable t)
          Write error message and throwable into the logger.
 void fatal(Object o)
          Write fatal error message into the logger.
 void fatal(Object o, Throwable t)
          Write fatal error message and throwable into the logger.
 NodeLogger.LEVEL getLevel()
          Returns the minimum logging retrieved from the underlying Log4J logger.
static NodeLogger getLogger(Class<?> c)
          Creates a new NodeLogger for the given Class.
static NodeLogger getLogger(String s)
          Creates a new NodeLogger for the given name.
 void info(Object o)
          Write info message into this logger.
 void info(Object o, Throwable t)
          Write info message and throwable into this logger.
 boolean isDebugEnabled()
          Checks if debug logging level is enabled.
 boolean isEnabledFor(NodeLogger.LEVEL level)
          Returns true if the underlying Log4J logger is enabled for the given level.
 boolean isInfoEnabled()
          Checks if info logging level is enabled.
static void removeWriter(Writer writer)
          Removes the previously added Writer from the logger.
static void setLevel(NodeLogger.LEVEL level)
          Sets an new minimum logging level for all internal appenders, that are, log file, and System.out and System.err appender.
static void setLevelIntern(NodeLogger.LEVEL level)
          Deprecated. 
 void warn(Object o)
          Write warning message into this logger.
 void warn(Object o, Throwable t)
          Write warning message and throwable into this logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE

public static final String LOG_FILE
The default log file name, knime.log.

See Also:
Constant Field Values
Method Detail

getLogger

public static NodeLogger getLogger(Class<?> c)
Creates a new NodeLogger for the given Class.

Parameters:
c - The logger's Class.
Returns:
A new logger for this Class.

getLogger

public static NodeLogger getLogger(String s)
Creates a new NodeLogger for the given name.

Parameters:
s - The logger's String.
Returns:
A new logger for the given name.

warn

public void warn(Object o)
Write warning message into this logger.

Parameters:
o - The object to print.

debug

public void debug(Object o)
Write debugging message into this logger.

Parameters:
o - The object to print.

info

public void info(Object o)
Write info message into this logger.

Parameters:
o - The object to print.

error

public void error(Object o)
Write error message into the logger.

Parameters:
o - The object to print.

fatal

public void fatal(Object o)
Write fatal error message into the logger.

Parameters:
o - The object to print.

warn

public void warn(Object o,
                 Throwable t)
Write warning message and throwable into this logger.

Parameters:
o - The object to print.
t - The exception to log at debug level, including its stack trace.

debug

public void debug(Object o,
                  Throwable t)
Write debugging message and throwable into this logger.

Parameters:
o - The object to print.
t - The exception to log, including its stack trace.

info

public void info(Object o,
                 Throwable t)
Write info message and throwable into this logger.

Parameters:
o - The object to print.
t - The exception to log at debug level, including its stack trace.

error

public void error(Object o,
                  Throwable t)
Write error message and throwable into the logger.

Parameters:
o - The object to print.
t - The exception to log at debug level, including its stack trace.

assertLog

public void assertLog(boolean b,
                      String m)
Check assert and write into logger if failed.

Parameters:
b - The expression to check.
m - Print this message if failed.

assertLog

public void assertLog(boolean b,
                      String m,
                      AssertionError e)
Check assertions on/off and write debug message into logger.

Parameters:
b - The expression to check.
m - Print this message if failed.
e - AssertionError which as been fired.

coding

public void coding(Object o)
Writes CODING PROBLEM plus this message into this logger as error.

Parameters:
o - The message to print.

coding

public void coding(Object o,
                   Throwable t)
Writes CODING PROBLEM plus this message, as well as the the message of the throwable into this logger as error and debug.

Parameters:
o - The message to print.
t - The exception to log at debug level, including its stack trace.

fatal

public void fatal(Object o,
                  Throwable t)
Write fatal error message and throwable into the logger.

Parameters:
o - The object to print.
t - The exception to log at debug level, including its stack trace.

addWriter

public static final void addWriter(Writer writer,
                                   NodeLogger.LEVEL minLevel,
                                   NodeLogger.LEVEL maxLevel)
Adds a new Writer with the given level to this logger.

Parameters:
writer - The writer to add.
minLevel - The minimum level to output.
maxLevel - The maximum level to output.

removeWriter

public static final void removeWriter(Writer writer)
Removes the previously added Writer from the logger.

Parameters:
writer - The Writer to remove.

setLevelIntern

@Deprecated
public static void setLevelIntern(NodeLogger.LEVEL level)
Deprecated. 

Parameters:
level - minimum log level
See Also:
setLevel(NodeLogger.LEVEL)

setLevel

public static void setLevel(NodeLogger.LEVEL level)
Sets an new minimum logging level for all internal appenders, that are, log file, and System.out and System.err appender. The maximum logging level stays LEVEL.ALL for all appenders.

Parameters:
level - new minimum logging level

getLevel

public NodeLogger.LEVEL getLevel()
Returns the minimum logging retrieved from the underlying Log4J logger.

Returns:
minimum logging level

isDebugEnabled

public boolean isDebugEnabled()
Checks if debug logging level is enabled.

Returns:
true if debug logging level is enabled, otherwise false

isInfoEnabled

public boolean isInfoEnabled()
Checks if info logging level is enabled.

Returns:
true if info logging level is enabled, otherwise false

isEnabledFor

public boolean isEnabledFor(NodeLogger.LEVEL level)
Returns true if the underlying Log4J logger is enabled for the given level.

Parameters:
level - to test logging enabled
Returns:
true if logging is enabled, otherwise false


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.