com.ibm.ecm.extension

Class PluginLogger

  1. java.lang.Object
  2. extended bycom.ibm.ecm.extension.PluginLogger

  1. public class PluginLogger
  2. extends java.lang.Object
Since:
2.0.2 This class performs logging to System.out. Logging is performed directly to the system console. (Note that we've tried other loggers, such as Apache commons logging and Java logging, and these have had problems due to interactions with WAS, II4C and ODWEK logging). The following code snippet shows how you might use the logger:
 public class TestClass {
        public void TestMethod(HttpServletRequest servletRequest) {
                        final String methodName = "TestMethod";
                        PluginLogger.logEntry(this,methodName"TestMethod",servletRequest);
                        ...
                        try {
                                ...
                                PluginLogger.logInfo(this,methodName,servletRequest,"Some function has completed");
                                ...
                        } catch (SomeException e) {
                                PluginLogger.logError(this,methodName,servletRequest,e);
                        } 
                        ...
                        PluginLogger.logExit(this,methodName,servletRequest);
                }
 }
 
For situations where the ServletRequest object is available, use the logging methods that take a ServletRequest parameter. This parameter will additionally log the userId, serverName, and sessionId.

Five logging levels are provided: Error, Warning, Info, Perf, and Debug. Accordingly, the following methods are provided to log at each of these levels: logError, logWarning, logInfo, logPerf, and logDebug, as well as logEntry and logExit methods (forms of logDebug). These logging levels should be used as follows:

Error
Use for logging exceptions or other serious error situations. Note: This level of logging should not be used to log exceptions that are normally expected and can be handled. In practice, however, most exceptions do indicate errors if the application is checking for valid user input prior to invoking an operation.
Warning
Use for logging information that might indicate a problem, and some default action has been taken. One situation this can occur is when some part of configuration is missing but operation continues. Note: This level of logging should not be used to log warning messages that were displayed to the user due to invalid values entered by the user. Try to keep the messages logged at this level understandable by administrators, in order to allow an administrator to resolve the configuration problem.
Info, Perf
Use to log information that might be useful for application developers, such as key actions taken (document deleted, search completed, page rendered, etc). Performance logging can also use this method, as this is normally useful to application developers. Try to keep the messages understandable by application developers by avoiding internal details.
Debug
Use to log detailed internal information. This includes method entry/exit information. This information is likely useful for internal development only. However, in certain situations an SE could request this level of logging from a customer to resolve a problem.

To set the logging level per plug-in, use the PluginLogger.setPluginLogLevel method.

To avoid overhead from debug logging, you can use the PluginLogger.isDebug test prior to calling PluginLogger.logDebug. This is especially important if the debug logging is within a loop.


Field Summary

Modifier and Type Field and Description
  1. static
  2. int
LOG_DEBUG
Constant: logging level: debugging messages
  1. static
  2. int
LOG_DEV
  1. static
  2. int
LOG_ENTRY
  1. static
  2. int
LOG_ERROR
Constant: logging level: error information
  1. static
  2. int
LOG_EXIT
  1. static
  2. int
LOG_INFO
Constant: logging level: relevant information about program operations.
  1. static
  2. int
LOG_PERF
  1. static
  2. int
LOG_WARNING
Constant: logging level: warning messages

Constructor Summary

Constructor and Description
PluginLogger(Plugin plugin)
PluginLogger(java.lang.String pluginId)

Method Summary

Modifier and Type Method and Description
  1. int
getLogLevel()
  1. java.lang.String
getPluginAppId()
  1. boolean
isDebugLogged()
Returns true if debug level logging is enabled.
  1. void
logDebug(java.lang.Object loggingObject,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String text)
  1. void
logDebug(java.lang.Object loggingObject,java.lang.String methodName,java.lang.String text)
Logs a debug message.
  1. void
logEntry(java.lang.Object object,java.lang.String methodName)
Logs method entry.
  1. void
logEntry(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request)
  1. void
logEntry(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String message)
  1. void
logEntry(java.lang.Object object,java.lang.String methodName,java.lang.String message)
  1. void
logError(java.lang.Object loggingObject,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String text)
  1. void
logError(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String text,java.lang.Throwable exception)
  1. void
logError(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.Throwable exception)
  1. void
logError(java.lang.Object loggingObject,java.lang.String methodName,java.lang.String text)
Logs error messages.
  1. void
logError(java.lang.Object object,java.lang.String methodName,java.lang.String text,java.lang.Throwable exception)
Logs an error containing both an exception and a message.
  1. void
logError(java.lang.Object object,java.lang.String methodName,java.lang.Throwable exception)
Logs exception information as an error.
  1. void
logExit(java.lang.Object object,java.lang.String methodName)
Logs method exit.
  1. void
logExit(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request)
  1. void
logExit(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String message)
  1. void
logExit(java.lang.Object object,java.lang.String methodName,java.lang.String message)
  1. void
logInfo(java.lang.Object loggingObject,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String text)
  1. void
logInfo(java.lang.Object loggingObject,java.lang.String methodName,java.lang.String text)
Logs an informational message.
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,java.util.Date date)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,java.util.Date date,java.lang.String message)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.util.Date date)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.util.Date date,java.lang.String message)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String message)
  1. java.util.Date
logPerf(java.lang.Object object,java.lang.String methodName,java.lang.String message)
  1. void
logWarning(java.lang.Object loggingObject,java.lang.String methodName,javax.servlet.ServletRequest request,java.lang.String text)
  1. void
logWarning(java.lang.Object loggingObject,java.lang.String methodName,java.lang.String text)
Logs a warning message.
  1. void
setLogLevel(int level)
Sets the logging level per plug-in.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

LOG_ERROR

  1. public static final int LOG_ERROR
Constant: logging level: error information

Errors are logged when program encounters a condition that prevents successful completion of the operation in progress.

See Also:

LOG_WARNING

  1. public static final int LOG_WARNING
Constant: logging level: warning messages
See Also:

LOG_INFO

  1. public static final int LOG_INFO
Constant: logging level: relevant information about program operations.

INFO logs indicate successful completion of the operation in progress.

See Also:

LOG_PERF

  1. public static final int LOG_PERF
See Also:

LOG_DEBUG

  1. public static final int LOG_DEBUG
Constant: logging level: debugging messages
See Also:

LOG_ENTRY

  1. public static final int LOG_ENTRY
See Also:

LOG_EXIT

  1. public static final int LOG_EXIT
See Also:

LOG_DEV

  1. public static final int LOG_DEV
See Also:

Constructor Detail

PluginLogger

  1. public PluginLogger(Plugin plugin)

PluginLogger

  1. public PluginLogger(java.lang.String pluginId)

Method Detail

getPluginAppId

  1. public java.lang.String getPluginAppId( )

getLogLevel

  1. public int getLogLevel()

setLogLevel

  1. public void setLogLevel(int level)
Sets the logging level per plug-in.
Parameters:
level - The logging level.

isDebugLogged

  1. public boolean isDebugLogged()
Returns true if debug level logging is enabled. This method can be used to conditionalize invocations of logDebug, in order to save processing time in formulating arguments to logDebug.

logEntry

  1. public void logEntry(java.lang.Object object,
  2. java.lang.String methodName)
Logs method entry. This version also takes a ServletRequest parameter.
Parameters:
object - The object from where the log is being written.
methodName - the method from where the log is being written.

logEntry

  1. public void logEntry(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request)

logEntry

  1. public void logEntry(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.lang.String message)

logEntry

  1. public void logEntry(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String message)

logExit

  1. public void logExit(java.lang.Object object,
  2. java.lang.String methodName)
Logs method exit. This version also takes a ServletRequest parameter.
Parameters:
object - The object from where the log is being written.
methodName - The method from where the log is being written.

logExit

  1. public void logExit(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request)

logExit

  1. public void logExit(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.lang.String message)

logExit

  1. public void logExit(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String message)

logError

  1. public void logError(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. java.lang.String text)
Logs error messages. This version also takes a ServletRequest parameter.
methodName - The method from where the log is being written.

logError

  1. public void logError(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String text)

logError

  1. public void logError(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.lang.Throwable exception)
Logs exception information as an error. This version also takes a ServletRequest parameter so that the server name, user Id, and session Id are logged.
Parameters:
object - The object from where the log is being written.
methodName - The method from where the log is being written.
exception - The exception to be logged.

logError

  1. public void logError(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.Throwable exception)

logError

  1. public void logError(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.lang.String text,
  4. java.lang.Throwable exception)
Logs an error containing both an exception and a message.
Parameters:
object - The object from where the log is being written.
methodName - The method from where the log is being written.
exception - The exception to be logged.

logError

  1. public void logError(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String text,
  5. java.lang.Throwable exception)

logWarning

  1. public void logWarning(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. java.lang.String text)
Logs a warning message. This version also takes a ServletRequest parameter.
methodName - The method from where the log is being written.

logWarning

  1. public void logWarning(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String text)

logInfo

  1. public void logInfo(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. java.lang.String text)
Logs an informational message. This version also takes a ServletRequest parameter.
methodName - The method from where the log is being written.

logInfo

  1. public void logInfo(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String text)

logDebug

  1. public void logDebug(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. java.lang.String text)
Logs a debug message. This version also takes a ServletRequest parameter.
methodName - The method from where the log is being written.

logDebug

  1. public void logDebug(java.lang.Object loggingObject,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String text)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName)
Returns:
The date. Use the returned date as input for the following logPerf method to echo out the elapsed time.

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.lang.String message)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.lang.String message)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.util.Date date)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.util.Date date)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. java.util.Date date,
  4. java.lang.String message)

logPerf

  1. public java.util.Date logPerf(java.lang.Object object,
  2. java.lang.String methodName,
  3. javax.servlet.ServletRequest request,
  4. java.util.Date date,
  5. java.lang.String message)