| |
|
| java.lang.Object com.protomatter.syslog.Syslog
Syslog | public class Syslog (Code) | | This class implements a system-wide logging utility. Please read the Syslog Whitepaper for more information. It
allows a program to log messages and objects at different severity levels in
a standardized way. The implementation of the log is specified by an object
which implements the Syslogger interface. You can have multiple log
implementations, and each can have it's own log mask or can inherit it's log
mask from Syslog (this is the default behavior).
There are 5 severity levels: DEBUG, INFO, WARNING, ERROR, FATAL. They
correspond to the numbers 0, 4, 8, 12, and 16, respectively. You can enable
logging for any combination of these levels. The default setting logs only
WARNING and above.
- Quickie introduction and usage:
-
Anywhere you're doing this:
System.out.println("Some message");
Do this instead: Syslog.debug(this, "Some
message");
If you're in a static method, do this:
Syslog.debug(MyClass.class, "Some message");
If you like what this gets you, start playing around with different
log levels (call "Syslog.info(...) " and others). If you
like that, start playing around with channels and configuring the
loggers and other things. Syslog has a very robust API and
can be bent around to do all sorts of things, but it does not
have to be complicated to use even though it can be
configured in all sorts of complicated ways.
|
|
- More involved usage examples:
-
// log simple message at DEBUG level
// pass 'this' as the object performing the logging
Syslog.log(this, "simple message", null, Syslog.DEBUG);
// this performs toString() on object 'obj', and prints a message
Syslog.log(this, "logging object", obj, Syslog.INFO);
// logs 'exception' and its stack trace at ERROR level
Syslog.log(this, exception);
// here's how you log in a static method -- pass the class object
Syslog.log(MyClass.class, "logging in MyClass");
// shortcuts for each log level Syslog.debug(this, "foo");
Syslog.debug(this, "foo", bar); Syslog.info(this, "foo");
Syslog.info(this, "foo", bar);
// log to multiple channels (the "foo" and "bar" channels)
Syslog.infoToChannel(this, new String[]{"foo", "bar"}, "My
message");
|
|
There are basically three types of methods on this class for issuing log
messages. Whenever a channel name is not specified, the channel
DEFAULT_CHANNEL is used.
Whenever a channel is specified, it is an Object . This argument
can either be a String or an array of String (in which
case, the message will be sent out to multiple channels).
- log(...);
- They have the following forms:
- log(Object logger, Throwable t);
log(Object logger, Throwable t, int level);
log(Object logger, Object msg, Object detail, int level);
log(Object logger, Object chan, Object msg, Object detail, int level);
log(InetAddress host, Object logger, Throwable t);
log(InetAddress host, Object logger, Throwable t, int level);
log(InetAddress host, Object logger, Object msg, Object detail, int
level);
log(InetAddress host, Object logger, Object chan, Object msg, Object
detail, int level);
- xxx(...);
- Where "xxx " is "debug ", "info ", "
warning ", "error ", or "fatal " These are
shortcuts to the log(...) method for each log level. They have
the following forms:
- xxx(Object logger, Object msg);
xxx(Object logger, Object msg, Object detail);
xxx(InetAddress host, Object logger, Object msg);
xxx(InetAddress host, Object logger, Object msg, Object detail);
- xxxToChannel(...);
- Where "xxx " is "debug ", "info ", "
warning ", "error ", or "fatal " These are
shortcuts to the log(...) method for each log level, and to a
specific channel. They have the following forms:
- xxxToChannel(Object logger, Object chan, Object msg);
xxxToChannel(Object logger, Object chan, Object msg, Object detail);
xxxToChannel(InetAddress host, Object logger, Object chan, Object msg);
xxxToChannel(InetAddress host, Object logger, Object chan, Object msg,
Object detail);
You may want to look at the Channel
class. Some people prefet its API.
When the Syslog class is loaded, the following happens:
- If the Syslog.level system property is set, it is passed to
Syslog.setLogMask(...) (otherwise it defaults to WARNING
).
- A PrintWriterLog named "PrintWriterLog.err " is
added using Syslog.addLogger(...) and connected to the
System.err PrintStream.
- If the Syslog.file system property is set, it is interpreted
as a filename and another PrintWriterLog is added and connected
to that file. The logger is named "PrintWriterLog.file ".
If you want to change these defaults, you can use the getLoggers()
, addLogger(...) , removeLogger(...) and
removeAllLoggers() methods to change what loggers are registered with
Syslog .
Syslog provides background work queues for loggers that need to perform
their operations asynchronously. For instance, the MailLog performs
its policy check synchronously and then if it decides that a message will
actually need to be sent, it asks syslog to perform the operation
asynchronously. This is far more efficient than doing everything in
the background because the amount of synchronization necessary to add work
to a queue is usually larger than a policy check.
Please read the Syslog Whitepaper
for more information on Syslog.
author: nate See Also: Syslogger See Also: SyslogChannelAware |
Field Summary | |
final public static String | ALL_CHANNEL The symbolic name for all channels. | final public static int | DEBUG A log generated during debugging of the software. | final public static String | DEFAULT_CHANNEL The name of the default log channel. | final public static int | ERROR One of the software components caused an error or exception. | final public static int | FATAL One of the software components is no longer functional. | final public static int | INFO An informational message that might come in handy later. | final public static int | INHERIT_MASK Loggers can inherit Syslog's log mask by setting their log mask to this
value. | public static String | SYSLOG_CHANNEL_NAME The name of a log channel for syslog configuration and system related
messages. | final public static int | WARNING A warning message that the system administrator might want to know
about. | final public static String | WARNING_PROPERTY Syslog classloader warning system property name. | public static Channel | channel A log channel for syslog configuration and system related messages. | public static int | currentLogMask The current system-wide log mask. | final public static Debug | debugging |
Constructor Summary | |
protected | Syslog() Protected constructor. |
Method Summary | |
final public static synchronized void | addLogger(Syslogger log) Registers a new Syslogger object with Syslog. | public static void | addWork(String queueName, Runnable r) Add work to the given background queue. | final public static int | atOrAbove(int level) | final public static boolean | canDebug() Determine if the current syslog mask would allow a message at the
DEBUG level to be logged. | final public static boolean | canDebug(Object logger) Pass-through to mightDebug(Object logger) . | final public static boolean | canError() Determine if the current syslog mask would allow a message at the
ERROR level to be logged. | final public static boolean | canError(Object logger) Pass-through to mightError(Object logger) . | final public static boolean | canFatal() Determine if the current syslog mask would allow a message at the
FATAL level to be logged. | final public static boolean | canFatal(Object logger) Pass-through to mightFatal(Object logger) . | final public static boolean | canInfo() Determine if the current syslog mask would allow a message at the
INFO level to be logged. | final public static boolean | canInfo(Object logger) Pass-through to mightInfo(Object logger) . | final public static boolean | canLog(int level) Determine if the current default syslog mask would allow the given level
of message to be logged. | final public static boolean | canLog(Object logger, int level) Pass-through to mightLog(Object logger, int level) . | final public static boolean | canWarning() Determine if the current syslog mask would allow a message at the
WARNING level to be logged. | final public static boolean | canWarning(Object logger) Pass-through to mightWarning(Object logger) . | final static String[] | convertChannelObject(Object channel) | final public static void | crumb() Logs a breadcrumb at the debug level. | final public static void | crumb(Object logger) Logs a breadcrumb at the debug level. | final public static void | crumb(Object logger, Object channel) Logs a breadcrumb at the debug level. | final public static void | debug(InetAddress host, Object logger, Object message) Logs a debug message, which will be converted through toString(). | final public static void | debug(InetAddress host, Object logger, Object message, Object detail) Logs a debug message with a detail object, both of which will be
converted through toString(). | final public static void | debug(Object logger, Object message) Logs a debug message, which will be converted through toString(). | final public static void | debug(Object logger, Object message, Object detail) Logs a debug message with a detail object, both of which will be
converted through toString(). | final public static void | debugToChannel(InetAddress host, Object logger, Object channel, Object message) Logs a debug message to the given channel. | final public static void | debugToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail) Logs a debug message with a detail object to the given channel. | final public static void | debugToChannel(Object logger, Object channel, Object message) Logs a debug message to the given channel. | final public static void | debugToChannel(Object logger, Object channel, Object message, Object detail) Logs a debug message with a detail object to the given channel. | final public static void | error(InetAddress host, Object logger, Object message) Logs a error message, which will be converted through toString(). | final public static void | error(InetAddress host, Object logger, Object message, Object detail) Logs a error message with a detail object, both of which will be
converted through toString(). | final public static void | error(Object logger, Object message) Logs a error message, which will be converted through toString(). | final public static void | error(Object logger, Object message, Object detail) Logs a error message with a detail object, both of which will be
converted through toString(). | final public static void | errorToChannel(InetAddress host, Object logger, Object channel, Object message) Logs an error message to the given channel. | final public static void | errorToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail) Logs an error message with a detail object to the given channel. | final public static void | errorToChannel(Object logger, Object channel, Object message) Logs an error message to the given channel. | final public static void | errorToChannel(Object logger, Object channel, Object message, Object detail) Logs an error message with a detail object to the given channel. | final public static void | fatal(InetAddress host, Object logger, Object message) Logs a fatal message, which will be converted through toString(). | final public static void | fatal(InetAddress host, Object logger, Object message, Object detail) Logs a fatal message with a detail object, both of which will be
converted through toString(). | final public static void | fatal(Object logger, Object message) Logs a fatal message, which will be converted through toString(). | final public static void | fatal(Object logger, Object message, Object detail) Logs a fatal message with a detail object, both of which will be
converted through toString(). | final public static void | fatalToChannel(InetAddress host, Object logger, Object channel, Object message) Logs a fatal message to the given channel. | final public static void | fatalToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail) Logs a fatal message with a detail object to the given channel. | final public static void | fatalToChannel(Object logger, Object channel, Object message) Logs a fatal message to the given channel. | final public static void | fatalToChannel(Object logger, Object channel, Object message, Object detail) Logs a fatal message with a detail object to the given channel. | public static void | flush() Flush output to all loggers. | public static boolean | getAlwaysComputeCaller() Get the flag for always computing calling class and method
names at runtime. | public static boolean | getComputeCaller() Get the flag for computing calling class and method
names at runtime. | public static long | getFlushThreadInterval() Get the sleep interval of the logger flush thread. | public static Syslog | getInstance() Returns the global Syslog instance. | public static InetAddress | getLocalHostName() Get the local hostname. | final public static int | getLogMask() Get the default mask for logging of messages. | public static String | getLogMaskAsString() Get a string representation of the current master log mask. | public static String | getLogMaskAsString(int logMask) Get a string representation of the given log mask. | final public static Syslogger | getLogger(String name) Get a logger by name. | final public static Iterator | getLoggers() Returns an Enumeration of all Syslogger objects registered with Syslog. | final public static String | getResourceString(String name) Get the value of the given resource name associated with Syslog. | final public static ResourceBundle | getResources() Get the resource bundle associated with Syslog. | public static Map | getWorkQueueMap() Get a map of the background work queues. | final public static boolean | inMask(int level, int mask) Check if the given level is covered by the given mask. | final public static void | info(InetAddress host, Object logger, Object message) Logs a info message, which will be converted through toString(). | final public static void | info(InetAddress host, Object logger, Object message, Object detail) Logs a info message with a detail object, both of which will be
converted through toString(). | final public static void | info(Object logger, Object message) Logs a info message, which will be converted through toString(). | final public static void | info(Object logger, Object message, Object detail) Logs a info message with a detail object, both of which will be
converted through toString(). | final public static void | infoToChannel(InetAddress host, Object logger, Object channel, Object message) Logs an info message to the given channel. | final public static void | infoToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail) Logs an info message with a detail object to the given channel. | final public static void | infoToChannel(Object logger, Object channel, Object message) Logs an info message to the given channel. | final public static void | infoToChannel(Object logger, Object channel, Object message, Object detail) Logs an info message with a detail object to the given channel. | final public static void | log(InetAddress host, Object logger, Object msg, Object detail, int level) Log a message. | final public static void | log(Object logger, Object msg, Object detail, int level) Log a message. | final public static void | log(Object logger, Object channel, Object msg, Object detail, int level) Log a message. | final public static void | log(InetAddress host, Object logger, Object channel, Object msg, Object detail, int level) Log a message. | final public static void | log(InetAddress host, Object logger, Object incomingChannel, Object msg, Object detail, int level, Thread thread, String threadName, long messageSendTime) Log a message. | final public static void | log(InetAddress host, Object logger, Object incomingChannel, Object msg, Object detail, int level, Thread thread, String threadName, long messageSendTime, int traceDepth) Log a message. | final public static void | log(InetAddress host, Object logger, Throwable e) Logs an exception for the given object. | final public static void | log(InetAddress host, Object logger, Throwable e, int level) Logs an exception for the given object at a given level. | final public static void | log(Object logger, Throwable e) Logs an exception for the given object. | final public static void | log(Object logger, Throwable e, int level) Logs an exception for the given object at a given level. | final public static boolean | mightDebug(Object logger) Determine if it's likely that someone will listen to a debug message
from the given logger. | final public static boolean | mightDebug(Object logger, Object channel) Determine if it's likely that someone will listen to a debug message
from the given logger on the given channel(s). | final public static boolean | mightError(Object logger) Determine if it's likely that someone will listen to an error message
from the given logger. | final public static boolean | mightError(Object logger, Object channel) Determine if it's likely that someone will listen to an error message
from the given logger on the given channel(s). | final public static boolean | mightFatal(Object logger) Determine if it's likely that someone will listen to a fatal message
from the given logger. | final public static boolean | mightFatal(Object logger, Object channel) Determine if it's likely that someone will listen to a fatal message
from the given logger on the given channel(s). | final public static boolean | mightInfo(Object logger) Determine if it's likely that someone will listen to an info message
from the given logger. | final public static boolean | mightInfo(Object logger, Object channel) Determine if it's likely that someone will listen to an info message
from the given logger on the given channel(s). | final public static boolean | mightLog(Object logger, int level) Determine if it's likely that someone will listen to a message from the
given logger at the given level. | final public static boolean | mightLog(Object logger, int level, Object channel) This method has been deprecated. | final public static boolean | mightWarning(Object logger) Determine if it's likely that someone will listen to a warning message
from the given logger. | final public static boolean | mightWarning(Object logger, Object channel) Determine if it's likely that someone will listen to a warning message
from the given logger on the given channel(s). | final public static int | parseLogMask(String mask) Parse the mask. | final public static synchronized void | removeAllLoggers() Deregisters all Syslogger objects. | final public static synchronized boolean | removeLogger(Syslogger log) Deregisters a Syslogger object from Syslog. | public static void | setAlwaysComputeCaller(boolean setting) Set the flag for always computing calling class and method
names at runtime. | public static void | setComputeCaller(boolean setting) Set the flag for computing calling class and method
names at runtime. | public static void | setFlushThreadInterval(long interval) Set the number of milliseconds a flush thread should wait before
flushing output on each logger. | public static void | setLocalHostName() Set the local hostname automatically. | public static void | setLocalHostName(InetAddress host) Set the local hostname. | final public static void | setLogMask(int mask) Set the default mask for logging of messages. | final public static void | setLogMask(String mask) Set the mask. | public static void | setMasterSwitch(boolean value) Set the value of the master switch. | public static synchronized void | shutdown() Remove all the loggers and shut them down. | final public static void | warning(InetAddress host, Object logger, Object message) Logs a warning message, which will be converted through toString(). | final public static void | warning(InetAddress host, Object logger, Object message, Object detail) Logs a warning message with a detail object, both of which will be
converted through toString(). | final public static void | warning(Object logger, Object message) Logs a warning message, which will be converted through toString(). | final public static void | warning(Object logger, Object message, Object detail) Logs a warning message with a detail object, both of which will be
converted through toString(). | final public static void | warningToChannel(InetAddress host, Object logger, Object channel, Object message) Logs a warning message to the given channel. | final public static void | warningToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail) Logs a warning message with a detail object to the given channel. | final public static void | warningToChannel(Object logger, Object channel, Object message) Logs a warning message to the given channel. | final public static void | warningToChannel(Object logger, Object channel, Object message, Object detail) Logs a warning message with a detail object to the given channel. | static String | whereAmI(int depth) |
ALL_CHANNEL | final public static String ALL_CHANNEL(Code) | | The symbolic name for all channels.
|
DEBUG | final public static int DEBUG(Code) | | A log generated during debugging of the software.
|
DEFAULT_CHANNEL | final public static String DEFAULT_CHANNEL(Code) | | The name of the default log channel.
|
ERROR | final public static int ERROR(Code) | | One of the software components caused an error or exception.
|
FATAL | final public static int FATAL(Code) | | One of the software components is no longer functional.
|
INFO | final public static int INFO(Code) | | An informational message that might come in handy later.
|
INHERIT_MASK | final public static int INHERIT_MASK(Code) | | Loggers can inherit Syslog's log mask by setting their log mask to this
value.
|
SYSLOG_CHANNEL_NAME | public static String SYSLOG_CHANNEL_NAME(Code) | | The name of a log channel for syslog configuration and system related
messages.
|
WARNING | final public static int WARNING(Code) | | A warning message that the system administrator might want to know
about.
|
WARNING_PROPERTY | final public static String WARNING_PROPERTY(Code) | | Syslog classloader warning system property name.
|
channel | public static Channel channel(Code) | | A log channel for syslog configuration and system related messages.
|
currentLogMask | public static int currentLogMask(Code) | | The current system-wide log mask. This variable is exposed so that
policies that inherit their mask from Syslog can get the value faster
than by calling a method.
|
Syslog | protected Syslog()(Code) | | Protected constructor. Please don't make a subclass of Syslog
unless you really know what you're doing.
|
addLogger | final public static synchronized void addLogger(Syslogger log)(Code) | | Registers a new Syslogger object with Syslog.
Parameters: log - The feature to be added to the Logger attribute |
addWork | public static void addWork(String queueName, Runnable r)(Code) | | Add work to the given background queue. Queues are created (but not
destroyed) dynamically.
Parameters: queueName - The feature to be added to the Work attribute Parameters: r - The feature to be added to the Work attribute |
atOrAbove | final public static int atOrAbove(int level)(Code) | | Parameters: level - The minimum severity of messages the log mask for "all logs at or above this level" |
canDebug | final public static boolean canDebug()(Code) | | Determine if the current syslog mask would allow a message at the
DEBUG level to be logged.
True if it is likely to be logged |
canDebug | final public static boolean canDebug(Object logger)(Code) | | Pass-through to mightDebug(Object logger) .
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightDebug(Object) |
canError | final public static boolean canError()(Code) | | Determine if the current syslog mask would allow a message at the
ERROR level to be logged.
True if it is likely to be logged See Also: Syslog.canLog(int) |
canError | final public static boolean canError(Object logger)(Code) | | Pass-through to mightError(Object logger) .
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightError(Object) |
canFatal | final public static boolean canFatal()(Code) | | Determine if the current syslog mask would allow a message at the
FATAL level to be logged.
True if it is likely to be logged See Also: Syslog.canLog(int) |
canFatal | final public static boolean canFatal(Object logger)(Code) | | Pass-through to mightFatal(Object logger) .
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightFatal(Object) |
canInfo | final public static boolean canInfo()(Code) | | Determine if the current syslog mask would allow a message at the
INFO level to be logged.
True if it is likely to be logged |
canInfo | final public static boolean canInfo(Object logger)(Code) | | Pass-through to mightInfo(Object logger) .
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightInfo(Object) |
canLog | final public static boolean canLog(int level)(Code) | | Determine if the current default syslog mask would allow the given level
of message to be logged. This is not an absolute method of determining
if a message would be logged by some registered logger. If there is a
registered logger who is not inheriting the mask from Syslog
itself, it may (or may not) have logged the message.
Parameters: level - Message severity to test True if it is likely to be logged |
canLog | final public static boolean canLog(Object logger, int level)(Code) | | Pass-through to mightLog(Object logger, int level) .
Parameters: logger - Calling object Parameters: level - Message severity True if it is likely to be logged See Also: Syslog.mightLog(Object,int) |
canWarning | final public static boolean canWarning()(Code) | | Determine if the current syslog mask would allow a message at the
WARNING level to be logged.
True if it is likely to be logged |
canWarning | final public static boolean canWarning(Object logger)(Code) | | Pass-through to mightWarning(Object logger) .
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightWarning(Object) |
crumb | final public static void crumb()(Code) | | Logs a breadcrumb at the debug level. The breadcrumb
includes information from a StackTraceInfo
object.
|
crumb | final public static void crumb(Object logger)(Code) | | Logs a breadcrumb at the debug level. The breadcrumb
includes information from a StackTraceInfo
object.
|
crumb | final public static void crumb(Object logger, Object channel)(Code) | | Logs a breadcrumb at the debug level.
|
debug | final public static void debug(InetAddress host, Object logger, Object message)(Code) | | Logs a debug message, which will be converted through toString().
Parameters: host - hostname Parameters: logger - Calling object Parameters: message - Message to log |
debug | final public static void debug(InetAddress host, Object logger, Object message, Object detail)(Code) | | Logs a debug message with a detail object, both of which will be
converted through toString().
Parameters: host - hostname Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
debug | final public static void debug(Object logger, Object message)(Code) | | Logs a debug message, which will be converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log |
debug | final public static void debug(Object logger, Object message, Object detail)(Code) | | Logs a debug message with a detail object, both of which will be
converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
debugToChannel | final public static void debugToChannel(InetAddress host, Object logger, Object channel, Object message)(Code) | | Logs a debug message to the given channel.
Parameters: host - hostname Parameters: logger - Calling object Parameters: message - Message to log |
debugToChannel | final public static void debugToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail)(Code) | | Logs a debug message with a detail object to the given channel.
Parameters: host - hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
debugToChannel | final public static void debugToChannel(Object logger, Object channel, Object message)(Code) | | Logs a debug message to the given channel.
Parameters: logger - Calling object Parameters: message - Message to log Parameters: channel - Channel to log message on |
debugToChannel | final public static void debugToChannel(Object logger, Object channel, Object message, Object detail)(Code) | | Logs a debug message with a detail object to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
error | final public static void error(InetAddress host, Object logger, Object message)(Code) | | Logs a error message, which will be converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log |
error | final public static void error(InetAddress host, Object logger, Object message, Object detail)(Code) | | Logs a error message with a detail object, both of which will be
converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
error | final public static void error(Object logger, Object message)(Code) | | Logs a error message, which will be converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log |
error | final public static void error(Object logger, Object message, Object detail)(Code) | | Logs a error message with a detail object, both of which will be
converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
errorToChannel | final public static void errorToChannel(InetAddress host, Object logger, Object channel, Object message)(Code) | | Logs an error message to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
errorToChannel | final public static void errorToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail)(Code) | | Logs an error message with a detail object to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
errorToChannel | final public static void errorToChannel(Object logger, Object channel, Object message)(Code) | | Logs an error message to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
errorToChannel | final public static void errorToChannel(Object logger, Object channel, Object message, Object detail)(Code) | | Logs an error message with a detail object to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
fatal | final public static void fatal(InetAddress host, Object logger, Object message)(Code) | | Logs a fatal message, which will be converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log |
fatal | final public static void fatal(InetAddress host, Object logger, Object message, Object detail)(Code) | | Logs a fatal message with a detail object, both of which will be
converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
fatal | final public static void fatal(Object logger, Object message)(Code) | | Logs a fatal message, which will be converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log |
fatal | final public static void fatal(Object logger, Object message, Object detail)(Code) | | Logs a fatal message with a detail object, both of which will be
converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
fatalToChannel | final public static void fatalToChannel(InetAddress host, Object logger, Object channel, Object message)(Code) | | Logs a fatal message to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
fatalToChannel | final public static void fatalToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail)(Code) | | Logs a fatal message with a detail object to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
fatalToChannel | final public static void fatalToChannel(Object logger, Object channel, Object message)(Code) | | Logs a fatal message to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
fatalToChannel | final public static void fatalToChannel(Object logger, Object channel, Object message, Object detail)(Code) | | Logs a fatal message with a detail object to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
flush | public static void flush()(Code) | | Flush output to all loggers.
|
getAlwaysComputeCaller | public static boolean getAlwaysComputeCaller()(Code) | | Get the flag for always computing calling class and method
names at runtime. Default is false. If this is
set to true then the correct method name and caller
are always computed so they are available to the
log policies. This can be overly expensive if you have
lots of debug statements. If this flag is set to false
then the caller class and method are only computed if
the log call passes the policy check, and if the
getComputeCallingClassAndMethod() flag is also
set to true.
|
getComputeCaller | public static boolean getComputeCaller()(Code) | | Get the flag for computing calling class and method
names at runtime. Default is false.
|
getFlushThreadInterval | public static long getFlushThreadInterval()(Code) | | Get the sleep interval of the logger flush thread. This method will
either return the number of milliseconds between flush calls, or zero if
there is no flush thread running.
The flushThreadInterval value |
getInstance | public static Syslog getInstance()(Code) | | Returns the global Syslog instance. You really should not need to get
ahold of it, as all the methods are static. You might want to get it so
that you can keep an instance around to keep the class from being
unloaded if you're writing application servers.
The instance value |
getLocalHostName | public static InetAddress getLocalHostName()(Code) | | Get the local hostname.
The localHostName value |
getLogMask | final public static int getLogMask()(Code) | | Get the default mask for logging of messages.
The logMask value |
getLogMaskAsString | public static String getLogMaskAsString()(Code) | | Get a string representation of the current master log mask.
The logMaskAsString value |
getLogMaskAsString | public static String getLogMaskAsString(int logMask)(Code) | | Get a string representation of the given log mask.
Parameters: logMask - The parsed log mask The log mask rendered as a string |
getLogger | final public static Syslogger getLogger(String name)(Code) | | Get a logger by name. If there are multiple loggers with the same name,
the first one registered with that name will be returned. If there is no
logger by that name, null is returned.
Parameters: name - The name of the logger to get. The logger |
getLoggers | final public static Iterator getLoggers()(Code) | | Returns an Enumeration of all Syslogger objects registered with Syslog.
The loggers value |
getResourceString | final public static String getResourceString(String name)(Code) | | Get the value of the given resource name associated with Syslog.
Parameters: name - Resource name to get The resourceString value |
getResources | final public static ResourceBundle getResources()(Code) | | Get the resource bundle associated with Syslog.
The resources value |
getWorkQueueMap | public static Map getWorkQueueMap()(Code) | | Get a map of the background work queues. The key to the map is the name
of the queue, and the value is a
com.protomatter.util.WorkQueue com.protomatter.util.WorkQueue
object. You should never play with the queues -- this method is
provided so that external processes can monitor the size of each queue
by calling the getObjectPoolSize() method on each queue. The
map itself is read-only.
The workQueueMap value |
inMask | final public static boolean inMask(int level, int mask)(Code) | | Check if the given level is covered by the given mask.
Parameters: level - Log message severity Parameters: mask - Log mask to compare it to true if the given level is "in" the mask. |
info | final public static void info(InetAddress host, Object logger, Object message)(Code) | | Logs a info message, which will be converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log |
info | final public static void info(InetAddress host, Object logger, Object message, Object detail)(Code) | | Logs a info message with a detail object, both of which will be
converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
info | final public static void info(Object logger, Object message)(Code) | | Logs a info message, which will be converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log |
info | final public static void info(Object logger, Object message, Object detail)(Code) | | Logs a info message with a detail object, both of which will be
converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
infoToChannel | final public static void infoToChannel(InetAddress host, Object logger, Object channel, Object message)(Code) | | Logs an info message to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
infoToChannel | final public static void infoToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail)(Code) | | Logs an info message with a detail object to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
infoToChannel | final public static void infoToChannel(Object logger, Object channel, Object message)(Code) | | Logs an info message to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
infoToChannel | final public static void infoToChannel(Object logger, Object channel, Object message, Object detail)(Code) | | Logs an info message with a detail object to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
log | final public static void log(InetAddress host, Object logger, Object msg, Object detail, int level)(Code) | | Log a message. Logs to the DEFAULT_CHANNEL channel.
Parameters: host - The machine the log entry originated on. Parameters: logger - The object which is perfoming the log. It's class namewill be extracted and added to the log. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can be null). Parameters: level - The level of the log entry. |
log | final public static void log(Object logger, Object msg, Object detail, int level)(Code) | | Log a message. Logs to the DEFAULT_CHANNEL channel.
Parameters: logger - The object which is perfoming the log. It's class namewill be extracted and added to the log. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can be null). Parameters: level - The level of the log entry. |
log | final public static void log(Object logger, Object channel, Object msg, Object detail, int level)(Code) | | Log a message. If detail is a subclass of Throwable
it's stack trace will be included in the output. If you want to log to a
channel other than DEFAULT_CHANNEL you will have to use this
method or one of the xxx ToChannel(...) methods.
Parameters: logger - The object which is perfoming the log. It's class namewill be extracted and added to the log. Parameters: channel - The log channel to write to. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can be null). Parameters: level - The level of the log entry. |
log | final public static void log(InetAddress host, Object logger, Object channel, Object msg, Object detail, int level)(Code) | | Log a message. If detail is a subclass of Throwable
it's stack trace will be included in the output. If you want to log to a
channel other than DEFAULT_CHANNEL you will have to use this
method or one of the xxx ToChannel(...) methods.
Parameters: host - The host the log message originated on. Parameters: logger - The object which is perfoming the log. It's class namewill be extracted and added to the log. Parameters: channel - The log channel to write to. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can be null). Parameters: level - The level of the log entry. |
log | final public static void log(InetAddress host, Object logger, Object incomingChannel, Object msg, Object detail, int level, Thread thread, String threadName, long messageSendTime)(Code) | | Log a message. This method should not be called unless it's by a
remote log adapter.
Parameters: host - The host the log message originated on. Parameters: logger - The object which is perfoming the log. It's classname will be extracted and added to the log. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can benull). Parameters: level - The level of the log entry. Parameters: thread - The thread making the log call (null if remote) Parameters: threadName - The name of the thread making the log call. Parameters: messageSendTime - The time the message was sent. Parameters: incomingChannel - Message channel |
log | final public static void log(InetAddress host, Object logger, Object incomingChannel, Object msg, Object detail, int level, Thread thread, String threadName, long messageSendTime, int traceDepth)(Code) | | Log a message. This method should not be called unless it's by a
remote log adapter.
Parameters: host - The host the log message originated on. Parameters: logger - The object which is perfoming the log. It's classname will be extracted and added to the log. Parameters: msg - A short message describing the log entry. Parameters: detail - A longer message with more information (can benull). Parameters: level - The level of the log entry. Parameters: thread - The thread making the log call (null if remote) Parameters: threadName - The name of the thread making the log call. Parameters: messageSendTime - The time the message was sent. Parameters: incomingChannel - Channel Parameters: traceDepth - Caller's depth in call stack, for computingcaller and method names at runtime. |
log | final public static void log(InetAddress host, Object logger, Throwable e)(Code) | | Logs an exception for the given object. The log level will be ERROR.
Parameters: host - hostname Parameters: logger - Calling object Parameters: e - exception to log |
log | final public static void log(InetAddress host, Object logger, Throwable e, int level)(Code) | | Logs an exception for the given object at a given level.
Parameters: host - hostname Parameters: logger - Calling object Parameters: e - exception to log Parameters: level - Severity to log the message at |
log | final public static void log(Object logger, Throwable e)(Code) | | Logs an exception for the given object. The log level will be ERROR.
Parameters: logger - Calling object Parameters: e - Exception to log |
log | final public static void log(Object logger, Throwable e, int level)(Code) | | Logs an exception for the given object at a given level.
Parameters: logger - Calling object Parameters: e - Exception to log Parameters: level - Severity to log the message at |
mightDebug | final public static boolean mightDebug(Object logger)(Code) | | Determine if it's likely that someone will listen to a debug message
from the given logger.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightDebug | final public static boolean mightDebug(Object logger, Object channel)(Code) | | Determine if it's likely that someone will listen to a debug message
from the given logger on the given channel(s).
Parameters: logger - Calling object Parameters: channel - Channel name or list True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightError | final public static boolean mightError(Object logger)(Code) | | Determine if it's likely that someone will listen to an error message
from the given logger.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightError | final public static boolean mightError(Object logger, Object channel)(Code) | | Determine if it's likely that someone will listen to an error message
from the given logger on the given channel(s).
Parameters: logger - Calling object Parameters: channel - Channel name or list True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightFatal | final public static boolean mightFatal(Object logger)(Code) | | Determine if it's likely that someone will listen to a fatal message
from the given logger.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightFatal | final public static boolean mightFatal(Object logger, Object channel)(Code) | | Determine if it's likely that someone will listen to a fatal message
from the given logger on the given channel(s).
Parameters: logger - Calling object Parameters: channel - Channel name or list True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightInfo | final public static boolean mightInfo(Object logger)(Code) | | Determine if it's likely that someone will listen to an info message
from the given logger.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightInfo | final public static boolean mightInfo(Object logger, Object channel)(Code) | | Determine if it's likely that someone will listen to an info message
from the given logger on the given channel(s).
Parameters: logger - Calling object Parameters: channel - Channel name or list True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightLog | final public static boolean mightLog(Object logger, int level)(Code) | | Determine if it's likely that someone will listen to a message from the
given logger at the given level.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightLog | final public static boolean mightLog(Object logger, int level, Object channel)(Code) | | This method has been deprecated. You should use the
com.protomatter.util.Debug
class instead.
Parameters: logger - Calling object Parameters: level - Message severity Parameters: channel - Channel to log message on True if it is likely to be logged |
mightWarning | final public static boolean mightWarning(Object logger)(Code) | | Determine if it's likely that someone will listen to a warning message
from the given logger.
Parameters: logger - Calling object True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
mightWarning | final public static boolean mightWarning(Object logger, Object channel)(Code) | | Determine if it's likely that someone will listen to a warning message
from the given logger on the given channel(s).
Parameters: logger - Calling object Parameters: channel - Channel name or list True if it is likely to be logged See Also: Syslog.mightLog(Object,int,Object) |
parseLogMask | final public static int parseLogMask(String mask)(Code) | | Parse the mask. If the value passed in is the name of a level, like "
INFO " or "WARNING " the mask will be set to at or
above the listed level. If the string passed in is "INHERIT_MASK
" then this policy will inherit the mask set in Syslog itself.
You can also pass in a list of levels, separated by commas and with an "
= " before each level to select non-contiguous groups of
levels. For instance, passing in "=INFO,=ERROR " will catch
messages only at the INFO and ERROR levels, and
NOTHING ELSE .
Parameters: mask - String representation of the mask Computed log mask |
removeAllLoggers | final public static synchronized void removeAllLoggers()(Code) | | Deregisters all Syslogger objects.
|
removeLogger | final public static synchronized boolean removeLogger(Syslogger log)(Code) | | Deregisters a Syslogger object from Syslog.
Parameters: log - The logger to remove true if the logger was removed |
setAlwaysComputeCaller | public static void setAlwaysComputeCaller(boolean setting)(Code) | | Set the flag for always computing calling class and method
names at runtime. Default is false.
|
setComputeCaller | public static void setComputeCaller(boolean setting)(Code) | | Set the flag for computing calling class and method
names at runtime. Default is false.
|
setFlushThreadInterval | public static void setFlushThreadInterval(long interval)(Code) | | Set the number of milliseconds a flush thread should wait before
flushing output on each logger. If the interval is 0 (or negative) the
thread will be stopped. The default is not to have a flush thread
running. You cannot set it to less than 1000ms, except for setting it to
0.
Parameters: interval - The new flushThreadInterval value |
setLocalHostName | public static void setLocalHostName()(Code) | | Set the local hostname automatically. This sets the hostname to whatever
InetAddress.getLocalHost() returns. This is called by
SimpleSyslogTextFormatter when it is configured if it is supposed
to log the host name.
|
setLocalHostName | public static void setLocalHostName(InetAddress host)(Code) | | Set the local hostname.
Parameters: host - The new localHostName value |
setLogMask | final public static void setLogMask(int mask)(Code) | | Set the default mask for logging of messages. For example, to log all
messages of type ERROR or greater, you would:
Syslog.setLogMask(Syslog.atOrAbove(ERROR));
Parameters: mask - The new logMask value |
setMasterSwitch | public static void setMasterSwitch(boolean value)(Code) | | Set the value of the master switch. If this switch is set to false
, then all log requests will be ignored.
Parameters: value - The new masterSwitch value |
shutdown | public static synchronized void shutdown()(Code) | | Remove all the loggers and shut them down. Waits for all background
queues to finish processing work. Any new messages received immediately
after this method is called (before it completes) will be ignored.
|
warning | final public static void warning(InetAddress host, Object logger, Object message)(Code) | | Logs a warning message, which will be converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log |
warning | final public static void warning(InetAddress host, Object logger, Object message, Object detail)(Code) | | Logs a warning message with a detail object, both of which will be
converted through toString().
Parameters: host - Hostname Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
warning | final public static void warning(Object logger, Object message)(Code) | | Logs a warning message, which will be converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log |
warning | final public static void warning(Object logger, Object message, Object detail)(Code) | | Logs a warning message with a detail object, both of which will be
converted through toString().
Parameters: logger - Calling object Parameters: message - Message to log Parameters: detail - Extended message or exception |
warningToChannel | final public static void warningToChannel(InetAddress host, Object logger, Object channel, Object message)(Code) | | Logs a warning message to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
warningToChannel | final public static void warningToChannel(InetAddress host, Object logger, Object channel, Object message, Object detail)(Code) | | Logs a warning message with a detail object to the given channel.
Parameters: host - Hostname Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
warningToChannel | final public static void warningToChannel(Object logger, Object channel, Object message)(Code) | | Logs a warning message to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log |
warningToChannel | final public static void warningToChannel(Object logger, Object channel, Object message, Object detail)(Code) | | Logs a warning message with a detail object to the given channel.
Parameters: logger - Calling object Parameters: channel - Channel to log message on Parameters: message - Message to log Parameters: detail - Extended message or exception |
|