com.ibm.commerce.foundation.common.util.logging
Class LoggingHelper
- java.lang.Object
-
- com.ibm.commerce.foundation.common.util.logging.LoggingHelper
-
public class LoggingHelper extends java.lang.Object
A utility class for creating a Java logger that is used for tracing and logging messages, constants, and methods used for standard tracing features that have not been defined by the logger APIs.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.util.logging.Level
DEFAULT_TRACE_LOG_LEVEL
The default trace level that standard code trace points should use.static java.util.logging.Level
ENTRY_EXIT_LOG_LEVEL
The log level used for entry and exit trace.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.String
capitalize(java.lang.String str)
capitalize the first letter of a stringstatic java.util.logging.Logger
getAdminLogger()
Returns the administrative logger associated with the default class.static java.util.logging.Logger
getAdminLogger(java.lang.Class loggedClass)
Returns the administrative logger associated with the specified class.static java.util.logging.Logger
getAdminLogger(java.lang.String loggedClassName)
Returns the administrative logger associated with the specified class name.static java.util.logging.Logger
getLogger(java.lang.Class loggedClass)
Returns the logger associated with the specified class.static java.util.logging.Logger
getLogger(java.lang.String loggedClassName)
Returns the logger associated with the specified class name.static java.util.logging.Logger
getServiceLogger()
Returns the logger associated with the default service logger class.static boolean
isEntryExitTraceEnabled(java.util.logging.Logger logger)
Determines whether entry and exit tracing is enabled for the specified logger.static boolean
isTraceEnabled(java.util.logging.Logger logger)
Returns whether the default trace is enabled for the specified logger.static void
logUnexpectedException(java.util.logging.Logger traceLogger, java.lang.String className, java.lang.String methodName, java.lang.Throwable exception)
Log an unexpected exception in the system.
-
-
-
Field Detail
-
ENTRY_EXIT_LOG_LEVEL
public static final java.util.logging.Level ENTRY_EXIT_LOG_LEVEL
The log level used for entry and exit trace. This constant is used for testing whether this level of trace is enabled.
-
DEFAULT_TRACE_LOG_LEVEL
public static final java.util.logging.Level DEFAULT_TRACE_LOG_LEVEL
The default trace level that standard code trace points should use. This trace level is for code trace points when tracing important steps and procedures in the code.
-
-
Method Detail
-
getLogger
public static java.util.logging.Logger getLogger(java.lang.Class loggedClass)
Returns the logger associated with the specified class. This logger is the package name the class belongs to.- Parameters:
loggedClass
- The class for which the logger is being returned for.- Returns:
- The logger for the specified class that can be used to log and trace messages.
-
getLogger
public static java.util.logging.Logger getLogger(java.lang.String loggedClassName)
Returns the logger associated with the specified class name. This logger is the package name the class name belongs to.- Parameters:
loggedClassName
- The class name for which the logger is being returned for.- Returns:
- The logger for the specified class name that can be used to log and trace messages.
-
getServiceLogger
public static java.util.logging.Logger getServiceLogger()
Returns the logger associated with the default service logger class.- Returns:
- The logger for the default service logger class that can be used to log and trace messages.
-
getAdminLogger
public static java.util.logging.Logger getAdminLogger()
Returns the administrative logger associated with the default class.- Returns:
- The logger for the default class that can be used to log and trace messages.
-
getAdminLogger
public static java.util.logging.Logger getAdminLogger(java.lang.Class loggedClass)
Returns the administrative logger associated with the specified class. This logger is the package name the class belongs to.- Parameters:
loggedClass
- The class for which the logger is being returned for.- Returns:
- The logger for the specified class that can be used to log and trace messages.
-
getAdminLogger
public static java.util.logging.Logger getAdminLogger(java.lang.String loggedClassName)
Returns the administrative logger associated with the specified class name. This logger is the package name the class name belongs to.- Parameters:
loggedClassName
- The class name for which the logger is being returned for.- Returns:
- The logger for the specified class name that can be used to log and trace messages.
-
isEntryExitTraceEnabled
public static boolean isEntryExitTraceEnabled(java.util.logging.Logger logger)
Determines whether entry and exit tracing is enabled for the specified logger. Sometimes entry and exit trace points will create objects so it is best to check if tracing is enabled before creating those objects.- Parameters:
logger
- The logger used for tracing.- Returns:
- Whether entry and exit trace is enabled for the specified logger.
-
isTraceEnabled
public static boolean isTraceEnabled(java.util.logging.Logger logger)
Returns whether the default trace is enabled for the specified logger.- Parameters:
logger
- The logger used for tracing.- Returns:
- Whether the default trace level is enabled for the specified logger.
-
logUnexpectedException
public static void logUnexpectedException(java.util.logging.Logger traceLogger, java.lang.String className, java.lang.String methodName, java.lang.Throwable exception)
Log an unexpected exception in the system. This method will ensure that we log a Level.SEVERE level exception on one line to notify administrators of unexpected behavior. The full stack will only be printed on the trace loggers if trace logs are enabled.- Parameters:
traceLogger
- The logger.className
- The name of class in which the exception occurs.methodName
- The name of the method in which the exception occurs.exception
- The exception to be logged.
-
capitalize
public static java.lang.String capitalize(java.lang.String str)
capitalize the first letter of a string- Parameters:
str
- the string to capitalize- Returns:
- the capitalized version.
-
-