public class JSR47Logger extends java.lang.Object implements Logger
A sample java.util.logging properties file - jsr47min.properties is provided that demonstrates
how to run with a memory based trace facility that runs with minimal performance
overhead. The memory buffer can be dumped when a log/trace record is written matching
the MemoryHandlers trigger level or when the push method is invoked on the MemoryHandler.
Debug
provides method to make it easy
to dump the memory buffer as well as other useful debug info.
Constructor and Description |
---|
JSR47Logger() |
Modifier and Type | Method and Description |
---|---|
void |
config(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Log a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
config(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Log a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
config(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable thrown)
Log a message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
void |
dumpTrace() |
void |
fine(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Trace a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
fine(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Trace a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
fine(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable ex) |
void |
finer(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Trace a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
finer(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Trace a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
finer(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable ex) |
void |
finest(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Trace a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
finest(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Trace a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
finest(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable ex) |
java.lang.String |
formatMessage(java.lang.String msg,
java.lang.Object[] inserts)
Format a log message without causing it to be written to the log.
|
void |
info(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Log a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
info(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Log a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
info(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable thrown)
Log a message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
void |
initialise(java.util.ResourceBundle logMsgCatalog,
java.lang.String loggerID,
java.lang.String resourceContext) |
boolean |
isLoggable(int level)
Check if a message of the given level would actually be logged by this
logger.
|
void |
log(int level,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable thrown)
Log a message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
void |
setResourceName(java.lang.String logContext)
Set a name that can be used to provide context with each log record.
|
void |
severe(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Log a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
severe(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Log a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
severe(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable thrown)
Log a message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
void |
trace(int level,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable ex)
Log a trace message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
void |
warning(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Log a message, specifying source class and method, if the logger is
currently enabled for the given message level.
|
void |
warning(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts)
Log a message, specifying source class and method, with an array of
object arguments, if the logger is currently enabled for the given
message level.
|
void |
warning(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] inserts,
java.lang.Throwable thrown)
Log a message, specifying source class and method, with an array of
object arguments and a throwable, if the logger is currently enabled for
the given message level.
|
public void initialise(java.util.ResourceBundle logMsgCatalog, java.lang.String loggerID, java.lang.String resourceContext)
initialise
in interface Logger
logMsgCatalog
- The resource bundle associated with this loggerloggerID
- The suffix for the loggerName (will be appeneded to org.eclipse.paho.client.mqttv3resourceContext
- A context for the logger e.g. clientID or appName...public void setResourceName(java.lang.String logContext)
Logger
setResourceName
in interface Logger
public boolean isLoggable(int level)
Logger
isLoggable
in interface Logger
level
- a message logging level.public void severe(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
severe
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used.public void severe(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
severe
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.public void severe(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable thrown)
Logger
severe
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.thrown
- Throwable associated with log message.public void warning(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
warning
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used.public void warning(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
warning
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.public void warning(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable thrown)
Logger
warning
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.thrown
- Throwable associated with log message.public void info(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
info
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used.public void info(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
info
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.public void info(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable thrown)
Logger
info
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.thrown
- Throwable associated with log message.public void config(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
config
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used.public void config(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
config
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.public void config(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable thrown)
Logger
config
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.thrown
- Throwable associated with log message.public void log(int level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable thrown)
Logger
log
in interface Logger
level
- One of the message level identifiers, e.g. SEVERE.sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message, may be null.thrown
- Throwable associated with log message.public void fine(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
fine
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used.public void fine(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
fine
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used. The
formatter uses java.text.MessageFormat style formatting to
format parameters, so for example a format string "{0} {1}"
would format two inserts into the message.inserts
- Array of parameters to the message.public void fine(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable ex)
public void finer(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
finer
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used.public void finer(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
finer
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used. The
formatter uses java.text.MessageFormat style formatting to
format parameters, so for example a format string "{0} {1}"
would format two inserts into the message.inserts
- Array of parameters to the message.public void finer(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable ex)
public void finest(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
Logger
finest
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used.public void finest(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts)
Logger
finest
in interface Logger
sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used. The
formatter uses java.text.MessageFormat style formatting to
format parameters, so for example a format string "{0} {1}"
would format two inserts into the message.inserts
- Array of parameters to the message.public void finest(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable ex)
public void trace(int level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] inserts, java.lang.Throwable ex)
Logger
trace
in interface Logger
level
- One of the message level identifiers, e.g. SEVERE.sourceClass
- Name of class that issued the logging request.sourceMethod
- Name of method that issued the logging request.msg
- The key in the message catalog for the message or the actual
message itself. During formatting, if the logger has a mapping
for the msg string, then the msg string is replaced by the
value. Otherwise the original msg string is used. The
formatter uses java.text.MessageFormat style formatting to
format parameters, so for example a format string "{0} {1}"
would format two inserts into the message.inserts
- Array of parameters to the message, may be null.public java.lang.String formatMessage(java.lang.String msg, java.lang.Object[] inserts)
Logger
formatMessage
in interface Logger
msg
- The key in the message localization catalog for the message or
the actual message itself. During formatting, if the logger
has a mapping for the msg string, then the msg string is
replaced by the localized value. Otherwise the original msg
string is used. The formatter uses java.text.MessageFormat
style formatting to format parameters, so for example a format
string "{0} {1}" would format two inserts into the message.inserts
- Array of parameters to the message.