public class Logger
extends Object
LogWriter
to do actual job.LogWriter
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG
For both Development and Production debugging.
|
static String |
DEBUG_STR |
static int |
FATAL
An error that renders the application useless, such as a "FileNotFound"
exception on a file that contains startup information.
|
static String |
FATAL_STR |
static int |
INFO
Informational only - no help desk or support is required.
|
static String |
INFO_STR |
static Map<String,Integer> |
LOG_LEVELS |
static int |
NO_TYPE |
static int |
SEVERE
An error that lets the application continue running, but needs to be
fixed.
|
static String |
SEVERE_STR |
static int |
WARNING
A recoverable error that will likely not need help desk or immediate
development support.
|
static String |
WARNING_STR |
Modifier and Type | Method and Description |
---|---|
static void |
addAppender(Object appender)
Adds the appender.
|
static void |
addAppender(Object object,
Object appender)
Adds the appender.
|
static Object |
getDefaultAppender(OutputStream stream)
Creates the default appender which outputs to the stream.
|
static LogWriter |
getLogger()
Return a reference to the
LogWriter implementation. |
static String |
log(int logType,
Object object,
String message)
Logs a message.
|
static String |
log(int logType,
Object object,
String message,
Throwable throwable)
Logs a message.
|
static void |
removeAppender(Object appender)
Removes the appender.
|
static void |
removeAppender(Object object,
Object appender)
Removes the appender.
|
static void |
setLevel(int level)
Sets the log levelt.
|
static void |
setLevel(Object object,
int level)
Sets the log level for the object.
|
static void |
setLogger(LogWriter theLogger)
Set the
LogWriter |
public static final int INFO
public static final String INFO_STR
public static final int DEBUG
public static final String DEBUG_STR
public static final int WARNING
public static final String WARNING_STR
public static final int SEVERE
public static final String SEVERE_STR
public static final int FATAL
public static final String FATAL_STR
public static final int NO_TYPE
public static Map<String,Integer> LOG_LEVELS
public static void addAppender(Object appender)
appender
- the appenderpublic static void addAppender(Object object, Object appender)
object
- the objectappender
- the appenderpublic static Object getDefaultAppender(OutputStream stream)
stream
- the streampublic static LogWriter getLogger()
LogWriter
implementation. You will
not normally need to invoke this unless you want to invoke methods on the
implementation that are not on the LogWriter interface. (You'll need to
cast it back to the underlying implementation).public static String log(int logType, Object object, String message)
logType
- The type of log that is being written. Common types are
"info", "debug", "warning", "fatal", etc.object
- The object that is writing the message. If the object is a
static class (such as Logger), pass the Class object instead -
e.g., "Logger.class". Null is acceptable.message
- The actual message to write to the log. Null is acceptable,
but why would you?public static String log(int logType, Object object, String message, Throwable throwable)
logType
- The type of log that is being written. Common types are
"info", "debug", "warning", "fatal", etc.object
- The object that is writing the message. If the object is a
static class (such as Logger), pass the Class object instead -
e.g., "Logger.class". Null is acceptable.message
- The actual message to write to the log. Null is acceptable,
but why would you?throwable
- Any Throwable whose contents you want written with the log
message. The Throwable's cause is check recursively and
displays all causes in an abbreviated format.public static void removeAppender(Object appender)
appender
- the appenderpublic static void removeAppender(Object object, Object appender)
object
- the objectappender
- the appenderpublic static void setLevel(int level)
level
- The type of log that is being written. Common types are
"info", "debug", "warning", "fatal", etc.public static void setLevel(Object object, int level)
object
- The object that is writing the message.level
- The type of log that is being written. Common types are
"info", "debug", "warning", "fatal", etc.public static void setLogger(LogWriter theLogger)
LogWriter
theLogger
- Any implementation of LogWriter. This method lets you swap out
the default LogWriter - which simply writes to the console -
with LogWriters that write to files, databases, central JNDI
components that log for all running instances of a server app,
etc. Null is not allowed.Copyright © 2010-2020 Toolsverse. All Rights Reserved.