|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compoze.collab.log.Logger
public class Logger
This is the main class that clients use to do logging. Implementing logging
using this class consists of the following:
EntryPrototype
instances for each log message
ILogListener
implementations to receive log events
Logger
instance using Logger.createLogger()
Logger.log()
methods with your prototypes and arguments
to create log entries
Method Summary | |
---|---|
static void |
addDefaultListener(ILogListener listener)
Adds a default log listener (immediately affects every Logger
that has not changed its listeners from the default). |
void |
addListener(ILogListener listener)
Adds a listener to this logger. |
static Logger |
createLogger(String sName,
ILogContext logContext,
com.compoze.collab.resource.ResourceBundleCache bundle,
Logger parent)
Creates a named logger that pulls its logging context from the specified object. |
static Logger |
createLogger(String sName,
ILogContext logContext,
String sResourceBaseName,
Logger parent)
Creates a named logger that pulls its logging context from the specified object. |
static List |
getDefaultListeners()
Gets the default log listeners. |
static LogLevel |
getDefaultLogLevel()
Gets the default log level. |
List |
getListeners()
Gets the log listeners registered for this logger. |
LogLevel |
getLogLevel()
Gets the log level. |
PrintWriter |
getLogWriter(LogLevel level)
Gets a PrintWriter which will write a log entry
for each line that is written to the writer (println should
be used to write a line). |
String |
getName()
Gets the name of the logger. |
boolean |
isLogEnabled(LogEntryPrototype prototype)
Determines if logging is enabled for a prototype. |
void |
log(LogEntryPrototype prototype)
Logs a message. |
void |
log(LogEntryPrototype prototype,
Object arg)
Logs an event. |
void |
log(LogEntryPrototype prototype,
Object[] args)
Logs an event. |
void |
log(LogLevel level,
String s)
Logs a single String argument using a default log entry
prototype. |
void |
log(Throwable t,
LogEntryPrototype prototype)
Logs an event. |
void |
log(Throwable t,
LogEntryPrototype prototype,
Object arg)
Logs an event. |
void |
log(Throwable t,
LogEntryPrototype prototype,
Object[] args)
Logs an event. |
static void |
removeAllDefaultListeners()
Removes all default log listeners. |
void |
removeAllListeners()
Removes all listeners from this logger. |
static boolean |
removeDefaultListener(ILogListener listener)
Removes a default log listener (immediately affects every Logger
that has not changed its listeners from the default). |
boolean |
removeListener(ILogListener listener)
Removes a listener from this logger. |
static void |
setDefaultLogLevel(LogLevel level)
Sets the default log level. |
void |
setLogLevel(LogLevel level)
Sets the log level (everything this level and more severe is logged). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void setDefaultLogLevel(LogLevel level)
setLogLevel
has not already been called, this is the level
that is used. When the default log level is changed, all loggers using
the default log level will change to the new level immediately.
level
- the default log level (not null
)public static LogLevel getDefaultLogLevel()
null
)public String getName()
public void setLogLevel(LogLevel level)
level
- the log level (not null
)public LogLevel getLogLevel()
(LogLevel)
has never been
called, this returns the default log level.
public boolean isLogEnabled(LogEntryPrototype prototype)
log
method itself will re-check whether or not logging is
enabled for a particular message, but the check itself takes little time
compared to how long it can take to instantiate a log message.
prototype
- the log entry prototype
true
if logging is enabled for the prototypepublic PrintWriter getLogWriter(LogLevel level)
PrintWriter
which will write a log entry
for each line that is written to the writer (println
should
be used to write a line).
level
- the log levelpublic void log(LogLevel level, String s)
String
argument using a default log entry
prototype. Using an explicit log entry prototype is preferred because it
can be properly internationalized, but this may be useful for debug or
tracing info that does not contain locale specific text.
public void log(LogEntryPrototype prototype)
prototype
- the log entry prototypepublic void log(LogEntryPrototype prototype, Object arg)
prototype
- the log entry prototypearg
- an argument for the log entry message (or
null
if there are no arguments)public void log(LogEntryPrototype prototype, Object[] args)
prototype
- the log entry prototypeargs
- arguments for the log entry message (or
null
if there are no arguments)public void log(Throwable t, LogEntryPrototype prototype)
t
- the throwable to logprototype
- the log entry prototypepublic void log(Throwable t, LogEntryPrototype prototype, Object arg)
t
- the throwable to logprototype
- the log entry prototypearg
- argument for the log entry message (or
null
if there are no arguments)public void log(Throwable t, LogEntryPrototype prototype, Object[] args)
t
- the throwable to logprototype
- the log entry prototypeargs
- arguments for the log entry message (or
null
if there are no arguments)public static List getDefaultListeners()
ILogListener
instances
that are the defaults for all loggers that have not changed
their listenerspublic static void addDefaultListener(ILogListener listener)
Logger
that has not changed its listeners from the default).
listener
- the listener to add (not null
)public static boolean removeDefaultListener(ILogListener listener)
Logger
that has not changed its listeners from the default).
listener
- the listener to remove
true
if the listener was removed, false
if the specified listener was not a defaultpublic static void removeAllDefaultListeners()
public void addListener(ILogListener listener)
listener
- the listener to add (not null
)public boolean removeListener(ILogListener listener)
listener
- the listener to remove (not null
)
true
if the listener was removed, false
if the specified listener was not registered for this loggerpublic void removeAllListeners()
public List getListeners()
ILogListener
instances
that are currently registeredpublic static Logger createLogger(String sName, ILogContext logContext, String sResourceBaseName, Logger parent)
sName
- the name of the loggerlogContext
- the log contextsResourceBaseName
- the base name of the resource bundleparent
- the parent logger to consult for resources
(may be null
if not parent exists for the new
logger)
public static Logger createLogger(String sName, ILogContext logContext, com.compoze.collab.resource.ResourceBundleCache bundle, Logger parent)
sName
- the name of the loggerlogContext
- the log contextbundle
- the resource bundle cacheparent
- the parent logger to consult for resources
(may be null
if not parent exists for the new
logger)
|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |