|
Spatial DataBlade JAVA API v8.21 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.spatial.util.Logger
public class Logger
Logs API messages.
Note: This class is used internally, to ensure logging functionality for API code running on JRE versions prior to 1.4. In a future version, this implementation will probably be deprecated. Instead, the "java.util.logging" package (defined in J2SE 1.4) will be used.
An instance of this class will log messages for the API.
Logger objects should not be created directly. Instead, logging should be
activated using the SpatialManager logging facade methods
SpatialManager.setLogWriter
and
SpatialManager.setLogLevel
.
Logging messages will be forwarded to a registered Writer object.
A Logger has a logging level associated with it, which reflects a minimum message level that this logger cares about. The log level can be dynamically changed by calls on the Logger.setLevel method.
On each logging call the Logger initially performs a check of the request level (e.g. Logger.SEVERE or Logger.INFO) against the effective log level of the logger. If the request level is lower than the log level, the logging call returns immediately.
Most of the logger output methods take a "msg" argument. This msg argument is a message code. Messages are stored in ResourceBundle fields inside SpatialManager. The format style used is the java.text.MessageFormat style, so for example a format string "{0} {1}" would format two parameters as strings.
The logging methods will take a log level, a message code, and optionally the originating class and method name, and some parameters to the message. There are also convenience methods for tracing method entries (the "entering" methods) and method returns (the "exiting" methods).
Field Summary | |
---|---|
static int |
ALL
ALL indicates that all messages should be logged. |
static int |
INFO
INFO is a message level for informational messages. |
static int |
OFF
OFF is a special level that can be used to turn off logging. |
static int |
SEVERE
SEVERE is a message level indicating a failure. |
static int |
WARNING
WARNING is a message level indicating a potential problem. |
Constructor Summary | |
---|---|
Logger()
Constructor |
Method Summary | |
---|---|
void |
entering(java.lang.String className,
java.lang.String methodName)
Logs a method entry. |
void |
exiting(java.lang.String className,
java.lang.String methodName)
Logs a method return. |
static Logger |
getInstance()
Finds or creates a logger object. |
int |
getLevel()
Gets the log level that has been specified for this Logger. |
MessageProvider |
getMessageProvider()
Gets the MessageProvider associated with this Logger. |
boolean |
isLoggable(int level)
Checks if a message of the given level would actually be logged by this logger. |
void |
log(int level,
int msg)
Logs a message, with no argument. |
void |
log(int level,
int msg,
java.lang.Object param)
Logs a message, with an object argument. |
void |
log(int level,
int msg,
java.lang.Object[] params)
Logs a message, with an array of object arguments. |
void |
log(int level,
int msg,
java.lang.Throwable ex)
Logs a message, with associated Throwable information. |
void |
log(int level,
java.lang.String className,
java.lang.String methodName,
int msg)
Logs a message with source class and method, with no arguments. |
void |
log(int level,
java.lang.String className,
java.lang.String methodName,
int msg,
java.lang.Object[] params)
Log a message with source class and method, with an array of object arguments. |
void |
log(int level,
java.lang.String className,
java.lang.String methodName,
int msg,
java.lang.Object[] params,
java.lang.Throwable ex)
Logs a message, specifying source class and method, with associated Throwable information. |
void |
setLevel(int newLevel)
Sets the log level specifying which message levels will be logged by this logger. |
void |
setMessageProvider(MessageProvider provider)
Sets a MessageProvider object to retrieve localized and formatted messages given a message code. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OFF
public static final int SEVERE
In general SEVERE messages should describe events that will prevent normal program execution.
public static final int WARNING
In general WARNING messages should describe events that indicate potential problems.
public static final int INFO
public static final int ALL
Constructor Detail |
---|
public Logger()
Method Detail |
---|
public static Logger getInstance()
public void setLevel(int newLevel)
newLevel
- the new value for the log levelpublic int getLevel()
public boolean isLoggable(int level)
level
- a message logging level
public void setMessageProvider(MessageProvider provider)
provider
- a MessageProviderpublic MessageProvider getMessageProvider()
public void log(int level, int msg)
If the logger is currently enabled for the given message level then a corresponding message is created and forwarded to registered output writer.
level
- One of the message level identifiers, e.g.
Logger.WARNINGmsg
- The message codepublic void log(int level, int msg, java.lang.Object param)
If the logger is currently enabled for the given message level then a corresponding message is created and forwarded to registered output writer.
level
- One of the message level identifiers, e.g.
Logger.WARNINGmsg
- The message codeparam
- parameter to the messagepublic void log(int level, int msg, java.lang.Object[] params)
If the logger is currently enabled for the given message level then a corresponding message is created and forwarded to registered output writer.
level
- One of the message level identifiers, e.g.
Logger.WARNINGmsg
- The message codeparams
- array of parameters to the messagepublic void log(int level, int msg, java.lang.Throwable ex)
If the logger is currently enabled for the given message level then a corresponding message is created and forwarded to registered output writer.
level
- One of the message level identifiers, e.g.
Logger.WARNINGmsg
- The message codethrown
- Throwable associated with log message.public void log(int level, java.lang.String className, java.lang.String methodName, int msg)
If the logger is currently enabled for the given message level then a corresponding message is created and forwarded to registered output writer.
level
- One of the message level identifiers, e.g.
Logger.WARNINGclassName
- name of class that issued the logging requestmethodName
- name of method that issued the logging requestmsg
- The message codepublic void log(int level, java.lang.String className, java.lang.String methodName, int msg, java.lang.Object[] params)
If the logger is currently enabled for the given message level then a corresponding LogRecord is created and forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g.
Logger.WARNINGclassName
- name of class that issued the logging requestmethodName
- name of method that issued the logging requestmsg
- The message codeparams
- Array of parameters associated to the messagepublic void log(int level, java.lang.String className, java.lang.String methodName, int msg, java.lang.Object[] params, java.lang.Throwable ex)
If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers.
Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.
level
- One of the message level identifiers, e.g.
Logger.WARNINGclassName
- name of class that issued the logging requestmethodName
- name of method that issued the logging requestmsg
- The message codeex
- Throwable object associated with log message.public void entering(java.lang.String className, java.lang.String methodName)
This is a convenience method that can be used to log entry to a method. A message with log level Logger.INFO and the given className and methodName is logged.
className
- name of class that issued the logging requestmethodName
- name of method that issued the logging requestpublic void exiting(java.lang.String className, java.lang.String methodName)
This is a convenience method that can be used to log returning from a method. A message with log level Logger.INFO and the given className and methodName is logged.
className
- name of class that issued the logging requestmethodName
- name of method that issued the logging request
|
Spatial DataBlade JAVA API v8.21 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |