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 String
ERROR string literal.private static final String
INFO string literal.static final String
Line separator.private final String
Logger name.private static long
Mark the time when this class gets loaded into memory.private static final String
WARN string literal. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SimpleULogger
(String name) Constructor is private to force construction through getLogger. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Log a message object with the DEBUG level.void
Log a parameterized message object at the DEBUG level.void
Log a message object with theDEBUG
level including the stack trace of theThrowable
t
passed as parameter.void
Log a parameterized message object at the DEBUG level.void
Log a message object with the ERROR level.void
Log a parameterized message object at the ERROR level.void
Log a message object with theERROR
level including the stack trace of theThrowable
t
passed as parameter.void
Log a parameterized message object at the ERROR level.static SimpleULogger
Creates a new instance.void
Log a message object with the INFO level.void
Log a parameterized message object at the INFO level.void
Log a message object with theINFO
level including the stack trace of theThrowable
t
passed as parameter.void
Log a parameterized message object at the INFO level.boolean
Is the logger instance enabled for the DEBUG level?boolean
Is the logger instance enabled for the ERROR level?boolean
Is the logger instance enabled for the INFO level?boolean
Is the logger instance enabled for the WARN level?private void
This is our internal implementation for logging regular (non-parameterized) log messages.private void
parameterizedLog
(String level, Object parameterizedMsg, Object param1, Object param2) For parameterized messages, first substitute parameters and then log.void
Log a message object with the WARN level.void
Log a parameterized message object at the WARN level.void
Log a message object with theWARN
level including the stack trace of theThrowable
t
passed as parameter.void
Log 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
INFO string literal.- See Also:
-
WARN_STR
WARN string literal.- See Also:
-
ERROR_STR
ERROR string literal.- See Also:
-
-
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:
isDebugEnabled
in interfaceULogger
- Returns:
- true if debug is enabled.
-
debug
Log a message object with the DEBUG level. -
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 a message object with theDEBUG
level including the stack trace of theThrowable
t
passed as parameter. -
log
This is our internal implementation for logging regular (non-parameterized) log messages.- Parameters:
level
- levelmessage
- messaget
- throwable
-
parameterizedLog
For parameterized messages, first substitute parameters and then log.- Parameters:
level
- levelparameterizedMsg
- message patternparam1
- param1param2
- param2
-
isInfoEnabled
public boolean isInfoEnabled()Is the logger instance enabled for the INFO level?- Specified by:
isInfoEnabled
in interfaceULogger
- Returns:
- true if debug is enabled.
-
info
Log a message object with the INFO level. -
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
Log a message object with theINFO
level including the stack trace of theThrowable
t
passed as parameter. -
isWarnEnabled
public boolean isWarnEnabled()Is the logger instance enabled for the WARN level?- Specified by:
isWarnEnabled
in interfaceULogger
- Returns:
- true if debug is enabled.
-
warn
Log a message object with the WARN level. -
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
Log a message object with theWARN
level including the stack trace of theThrowable
t
passed as parameter. -
isErrorEnabled
public boolean isErrorEnabled()Is the logger instance enabled for the ERROR level?- Specified by:
isErrorEnabled
in interfaceULogger
- Returns:
- true if debug is enabled.
-
error
Log a message object with the ERROR level. -
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
Log a message object with theERROR
level including the stack trace of theThrowable
t
passed as parameter.
-