Class SimpleULogger
- All Implemented Interfaces:
ULogger
System.out).
The output includes the relative time in milliseconds, thread name, level, logger name, and the message followed by the line separator for the host. In log4j terms it amounts to the "%r [%t] %level %logger - %m%n" pattern.
176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse.
225 [main] INFO examples.SortAlgo - Entered the sort method.
304 [main] INFO SortAlgo.DUMP - Dump of interger array:
317 [main] INFO SortAlgo.DUMP - Element [0] = 0
331 [main] INFO SortAlgo.DUMP - Element [1] = 1
343 [main] INFO examples.Sort - The next log statement should be an error msg.
346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array.
at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
at org.log4j.examples.Sort.main(Sort.java:64)
467 [main] INFO examples.Sort - Exiting main method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringERROR string literal.private static final StringINFO string literal.static final StringLine separator.private final StringLogger name.private static longMark the time when this class gets loaded into memory.private static final StringWARN string literal. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSimpleULogger(String name) Constructor is private to force construction through getLogger. -
Method Summary
Modifier and TypeMethodDescriptionvoidLog a message object with the DEBUG level.voidLog a parameterized message object at the DEBUG level.voidLog a message object with theDEBUGlevel including the stack trace of theThrowabletpassed as parameter.voidLog a parameterized message object at the DEBUG level.voidLog a message object with the ERROR level.voidLog a parameterized message object at the ERROR level.voidLog a message object with theERRORlevel including the stack trace of theThrowabletpassed as parameter.voidLog a parameterized message object at the ERROR level.static SimpleULoggerCreates a new instance.voidLog a message object with the INFO level.voidLog a parameterized message object at the INFO level.voidLog a message object with theINFOlevel including the stack trace of theThrowabletpassed as parameter.voidLog a parameterized message object at the INFO level.booleanIs the logger instance enabled for the DEBUG level?booleanIs the logger instance enabled for the ERROR level?booleanIs the logger instance enabled for the INFO level?booleanIs the logger instance enabled for the WARN level?private voidThis is our internal implementation for logging regular (non-parameterized) log messages.private voidparameterizedLog(String level, Object parameterizedMsg, Object param1, Object param2) For parameterized messages, first substitute parameters and then log.voidLog a message object with the WARN level.voidLog a parameterized message object at the WARN level.voidLog a message object with theWARNlevel including the stack trace of theThrowabletpassed as parameter.voidLog a parameterized message object at the WARN level.
-
Field Details
-
loggerName
Logger name. -
startTime
private static long startTimeMark the time when this class gets loaded into memory. -
LINE_SEPARATOR
Line separator. -
INFO_STR
-
WARN_STR
-
ERROR_STR
-
-
Constructor Details
-
SimpleULogger
Constructor is private to force construction through getLogger.- Parameters:
name- logger name
-
-
Method Details
-
getLogger
Creates a new instance.- Parameters:
name- logger name- Returns:
- logger.
-
isDebugEnabled
public boolean isDebugEnabled()Is the logger instance enabled for the DEBUG level?- Specified by:
isDebugEnabledin interfaceULogger- Returns:
- true if debug is enabled.
-
debug
-
debug
Log a parameterized message object at the DEBUG level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
debug
Log a parameterized message object at the DEBUG level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
debug
-
log
-
parameterizedLog
-
isInfoEnabled
public boolean isInfoEnabled()Is the logger instance enabled for the INFO level?- Specified by:
isInfoEnabledin interfaceULogger- Returns:
- true if debug is enabled.
-
info
-
info
Log a parameterized message object at the INFO level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
info
Log a parameterized message object at the INFO level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
info
-
isWarnEnabled
public boolean isWarnEnabled()Is the logger instance enabled for the WARN level?- Specified by:
isWarnEnabledin interfaceULogger- Returns:
- true if debug is enabled.
-
warn
-
warn
Log a parameterized message object at the WARN level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
warn
Log a parameterized message object at the WARN level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
warn
-
isErrorEnabled
public boolean isErrorEnabled()Is the logger instance enabled for the ERROR level?- Specified by:
isErrorEnabledin interfaceULogger- Returns:
- true if debug is enabled.
-
error
-
error
Log a parameterized message object at the ERROR level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
error
Log a parameterized message object at the ERROR level.This form is useful in avoiding the superflous object creation problem when invoking this method while it is disabled.
-
error
-