WebLogic Integration


com.bea.logging
Class LogCategory

java.lang.Object
  |
  +--org.apache.log4j.Category
        |
        +--com.bea.logging.LogCategory

public class LogCategory
extends org.apache.log4j.Category
implements ILogger, INestedDiagnosticContext

Class LogCategory is the Logging Framework's base Class for logging. It extends the Category class of the underlying implementation. It implements two interfaces: ILogger is the public interface to the logging facility. It is returned by the LogManager (c_categoryFactory) to clients wishing to log messages. The INestedDiagnosticContext interface simply exposes the methods of the underlying NDC class, without modifying their behavior.

Author:
Copyright © 2000, 2001 BEA Systems, Inc. All Rights Reserved.

Inner Class Summary
static class LogCategory.LogCategoryFactory
          A factory for LogCategoryinstances.
 
Field Summary
static LogCategory.LogCategoryFactory c_categoryFactory
           
 
Fields inherited from class org.apache.log4j.Category
additive, DEFAULT_CONFIGURATION_FILE, DEFAULT_CONFIGURATION_KEY, DEFAULT_INIT_OVERRIDE_KEY, defaultHierarchy, hierarchy, name, parent, priority, resourceBundle
 
Constructor Summary
LogCategory(java.lang.String strContext)
          Create a new logging category
 
Method Summary
 void addRuntimeDestination(java.io.PrintWriter writer)
          Add a new destination at runtime.
 void audit(java.lang.String strKey)
          Log a message with the audit priority using the strKey for message lookup.
 void audit(java.lang.String message, boolean isDirect)
          Log a message with the audit priority.
 void audit(java.lang.String strKey, java.lang.Object obj)
          Convenience method which allows the useer to log an audit message with one argument to fill into the template.
 void audit(java.lang.String strKey, java.lang.Object[] aInfo)
          Log a message with the audit priority.
 void audit(java.lang.Throwable exception)
          Log a message with the audit priority.
 void clearNDC()
          Clear any nested disgnostic information.
 java.util.Stack cloneNDCStack()
          Clone the diagnostic context for the current thread.
 void debug(java.lang.String strMessage)
          Log a message with the debug priority.
static void dumpCategories()
          This method will print the configuration for all Categories in the current default hierarchy.
 void error(java.lang.String strKey)
          Log a message with the error priority.
 void error(java.lang.String message, boolean isDirect)
          Log a message with the error priority.
 void error(java.lang.String strKey, java.lang.Object obj)
          Convenience method which allows the user to log an error message with one argument to fill into the template.
 void error(java.lang.String strKey, java.lang.Object[] aInfo)
          Log a message with the error priority.
 void error(java.lang.Throwable exception)
          Log a message with the error priority.
protected  java.lang.String formatMessage(java.lang.String strTemplateKey, java.lang.Object[] aObj)
          formatMessage is used to format a pattern with arguments passed in a Object[]
static LogCategory getCategory(org.apache.log4j.Hierarchy hierarchy, LogContext context, java.util.ResourceBundle bundle)
          This method is called by the LogManager to create an LogCategory instance.
protected  java.lang.String getCategoryInfo(org.apache.log4j.Category c)
           
 java.lang.String getI18NMessage(java.lang.String strKey)
          getI18NMessage(String) can be called to retrieve an Internationalized message string from a resource bundle.
 java.lang.String getI18NMessage(java.lang.String strKey, java.lang.Object obj)
          Another convenience method, which allows the user to pass a single argument for replacement in the message template, without having to create an Object[]
 java.lang.String getI18NMessage(java.lang.String strKey, java.lang.Object[] aInfo)
          getI18NMessage(String, Object[]) can be called to retrieve an Internationalized message string from a resource bundle.
static org.apache.log4j.Category getInstance(java.lang.String name)
          Overrides parent getInstance() using our own c_categoryFactory instance.
 java.io.PrintWriter getLogWriter()
           
 java.lang.String getNDC()
          Used when printing the diagnostic context.
 int getNDCDepth()
          Get the current nesting depth of this diagnostic context
 INestedDiagnosticContext getNDCInterface()
          Method returns an interface to the static NDC methods that this object can access.
 void info(java.lang.String strKey)
          Log a message with the info priority.
 void info(java.lang.String message, boolean isDirect)
          Log a message with the INFO priority.
 void info(java.lang.String strKey, java.lang.Object obj)
          Convenience method which allows the user to log a warn message with one argument to fill into the template.
 void info(java.lang.String strKey, java.lang.Object[] aInfo)
          Log a message with the warn priority.
 void inheritNDC(java.util.Stack stack)
          Inherit the diagnostic context of another thread.
 void popNDC()
          Clients should call this method before leaving a diagnostic context.
 void pushNDC(java.lang.String message)
          Push new diagnostic context information for the current thread.
 void removeNDC()
          Remove the diagnostic context for this thread
 void setNDCMaxDepth(int depth)
          Set maximum depth of this diagnostic context.
 void setPriority(int intPriority)
          This method overrides the method in super.
 void setPriority(LogPriority priority)
          This method overrides the method in super.
 void setPriority(java.lang.String strPriority)
          This method overrides the method in super.
 java.lang.String toString()
           
 void warn(java.lang.String strKey)
          Log a message with the warn priority.
 void warn(java.lang.String message, boolean isDirect)
          Log a message with the warn priority.
 void warn(java.lang.String strKey, java.lang.Object obj)
          Convenience method which allows the user to log a warn message with one argument to fill into the template.
 void warn(java.lang.String strKey, java.lang.Object[] aInfo)
          Log a message with the warn priority.
 void warn(java.lang.Throwable exception)
          Log a message with the error priority.
 
Methods inherited from class org.apache.log4j.Category
addAppender, assert, callAppenders, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getHierarchy, getInstance, getInstance, getName, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isDebugEnabled, isEnabledFor, isInfoEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setPriority, setResourceBundle, shutdown, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

c_categoryFactory

public static LogCategory.LogCategoryFactory c_categoryFactory
Constructor Detail

LogCategory

public LogCategory(java.lang.String strContext)
Create a new logging category

Parameters:
strContext - - identifies the category to log messages to...
Method Detail

getInstance

public static org.apache.log4j.Category getInstance(java.lang.String name)
Overrides parent getInstance() using our own c_categoryFactory instance.


getCategory

public static LogCategory getCategory(org.apache.log4j.Hierarchy hierarchy,
                                      LogContext context,
                                      java.util.ResourceBundle bundle)
This method is called by the LogManager to create an LogCategory instance.

Parameters:
hierarchy - - the category hierarchy to retrieve the LogCategory from; hierarchies are maintained for each active locale.
context - is a LogContext object containing the name of the LogCategory
bundle - - the message bundle for a log context; ResourceBundles are managed by the LogManager.

addRuntimeDestination

public void addRuntimeDestination(java.io.PrintWriter writer)
Add a new destination at runtime.
Specified by:
addRuntimeDestination in interface ILogger


getLogWriter

public java.io.PrintWriter getLogWriter()
Specified by:
getLogWriter in interface ILogger


setPriority

public void setPriority(int intPriority)
This method overrides the method in super. It sets the current LogCategory's priority to one of the established levels.
Specified by:
setPriority in interface ILogger

Parameters:
intPriority - is an integer that represents a logging priority level. See com.bea.logging.LogPriority for a set of static int values to use.

setPriority

public void setPriority(java.lang.String strPriority)
This method overrides the method in super. It sets the current LogCategory's priority to one of the established levels.
Specified by:
setPriority in interface ILogger

Parameters:
strPriority - is a String name for an existing priority level.

setPriority

public void setPriority(LogPriority priority)
This method overrides the method in super. It sets the current LogCategory's priority to one of the established levels.
Specified by:
setPriority in interface ILogger

Parameters:
priority - is a LogPriority object, which is constructed using one of the static int values in LogPriority as its argument.

getI18NMessage

public java.lang.String getI18NMessage(java.lang.String strKey)
getI18NMessage(String) can be called to retrieve an Internationalized message string from a resource bundle. Rather than logging the resulting message, this method simply returns it to the caller. This is a convenience method for users who wish to include an I18N message in a new exception for example.
Specified by:
getI18NMessage in interface ILogger

Parameters:
strKey - is a String key for lookup of a message in a ResourceBundle
Returns:
a String which is the message text (value) of the input key

getI18NMessage

public java.lang.String getI18NMessage(java.lang.String strKey,
                                       java.lang.Object[] aInfo)
getI18NMessage(String, Object[]) can be called to retrieve an Internationalized message string from a resource bundle. Rather than logging the resulting message, this method simply returns it to the caller. This is a convenience method for users who wish to include an I18N message in a new exception.
Specified by:
getI18NMessage in interface ILogger

Parameters:
strKey - is a String key for lookup of a message in a ResourceBundle
aInfo - is an Object[] of parameters to be replaced in the template returned by the key, strKey.
Returns:
a String which is the message text (value) of the input key, with the members of aInfo already replaced.

getI18NMessage

public java.lang.String getI18NMessage(java.lang.String strKey,
                                       java.lang.Object obj)
Another convenience method, which allows the user to pass a single argument for replacement in the message template, without having to create an Object[]
Specified by:
getI18NMessage in interface ILogger

Parameters:
strKey - is a String key for lookup of a message in a ResourceBundle
obj - is typically a String which will be added to an Object[], and replaced on the underlying message template.
Returns:
a String which is the message text (value) of the input key, with the obj param already replaced.

formatMessage

protected java.lang.String formatMessage(java.lang.String strTemplateKey,
                                         java.lang.Object[] aObj)
formatMessage is used to format a pattern with arguments passed in a Object[]

Parameters:
strTemplate - is a "pattern" used by MessageFormat object
aObj - is an Object[] of parameters for replacement in the Pattern
Returns:
a String which is the result of replacing the template keys with the values from the Object[] aObj

audit

public void audit(java.lang.String strKey)
Log a message with the audit priority using the strKey for message lookup. This method does not take any arguments for replacement in the final message. It simply returns the message associated with the @param strKey
Specified by:
audit in interface ILogger


audit

public void audit(java.lang.String message,
                  boolean isDirect)
Log a message with the audit priority.
Specified by:
audit in interface ILogger

Parameters:
message - is just that, don't use it as a key for lookup
isDirect - should be set to true (yeah, this is stupid) but necessary!

audit

public void audit(java.lang.String strKey,
                  java.lang.Object[] aInfo)
Log a message with the audit priority.
Specified by:
audit in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
aInfo - is an Object[] of params to use with the specified template

audit

public void audit(java.lang.String strKey,
                  java.lang.Object obj)
Convenience method which allows the useer to log an audit message with one argument to fill into the template.
Specified by:
audit in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
obj - is an object (typically a String) to use with the specified template

audit

public void audit(java.lang.Throwable exception)
Log a message with the audit priority.
Specified by:
audit in interface ILogger

Parameters:
exception - is the exception to log. We include a stack trace in the log message.

error

public void error(java.lang.String strKey)
Log a message with the error priority.
Specified by:
error in interface ILogger

Parameters:
strKey - used as a key for lookup of the actual message.

error

public void error(java.lang.String message,
                  boolean isDirect)
Log a message with the error priority.
Specified by:
error in interface ILogger

Parameters:
message - is just that, don't use it as a key for lookup
isDirect - should be set to true (yeah, this is stupid)

error

public void error(java.lang.String strKey,
                  java.lang.Object[] aInfo)
Log a message with the error priority.
Specified by:
error in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
aInfo - is an Object[] of params to use with the specified template

error

public void error(java.lang.String strKey,
                  java.lang.Object obj)
Convenience method which allows the user to log an error message with one argument to fill into the template.
Specified by:
error in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
obj - is an object (typically a String) to use with the specified template

error

public void error(java.lang.Throwable exception)
Log a message with the error priority.
Specified by:
error in interface ILogger

Parameters:
exception - is the exception to log. We include a stack trace in the log message.

warn

public void warn(java.lang.String strKey)
Log a message with the warn priority.
Specified by:
warn in interface ILogger

Parameters:
strKey - used as a key for lookup of the actual message.

warn

public void warn(java.lang.String message,
                 boolean isDirect)
Log a message with the warn priority.
Specified by:
warn in interface ILogger

Parameters:
message - is just that, don't use it as a key for lookup
isDirect - should be set to true (yeah, this is stupid)

warn

public void warn(java.lang.String strKey,
                 java.lang.Object[] aInfo)
Log a message with the warn priority.
Specified by:
warn in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
aInfo - is an Object[] of params to use with the specified template

warn

public void warn(java.lang.String strKey,
                 java.lang.Object obj)
Convenience method which allows the user to log a warn message with one argument to fill into the template.
Specified by:
warn in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
obj - is an object (typically a String) to use with the specified template

warn

public void warn(java.lang.Throwable exception)
Log a message with the error priority.
Specified by:
warn in interface ILogger

Parameters:
exception - is the exception to log. We include a stack trace in the log message.

info

public void info(java.lang.String strKey)
Log a message with the info priority.
Specified by:
info in interface ILogger

Parameters:
strKey - is a key for message lookup

info

public void info(java.lang.String message,
                 boolean isDirect)
Log a message with the INFO priority.
Specified by:
info in interface ILogger

Parameters:
message - is just that, don't use it as a key for lookup
isDirect - should be set to true (yeah, this is stupid)

info

public void info(java.lang.String strKey,
                 java.lang.Object[] aInfo)
Log a message with the warn priority.
Specified by:
info in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
aInfo - is an Object[] of params to use with the specified template

info

public void info(java.lang.String strKey,
                 java.lang.Object obj)
Convenience method which allows the user to log a warn message with one argument to fill into the template.
Specified by:
info in interface ILogger

Parameters:
strKey - is a String key for looking up the template in the resource bundle.
obj - is an object (typically a String) to use with the specified template

debug

public void debug(java.lang.String strMessage)
Log a message with the debug priority. DEBUG does not allow internationalization because these messages are typically of use to the developer only.
Specified by:
debug in interface ILogger

Parameters:
strMessage - is a message

getNDCInterface

public INestedDiagnosticContext getNDCInterface()
Method returns an interface to the static NDC methods that this object can access. It is wrapper for the client.
Specified by:
getNDCInterface in interface ILogger

Returns:
interface INestedDiagnosticContext

clearNDC

public void clearNDC()
Clear any nested disgnostic information.
Specified by:
clearNDC in interface INestedDiagnosticContext


cloneNDCStack

public java.util.Stack cloneNDCStack()
Clone the diagnostic context for the current thread.
Specified by:
cloneNDCStack in interface INestedDiagnosticContext

Returns:
a stack for the current NDC

getNDC

public java.lang.String getNDC()
Used when printing the diagnostic context.
Specified by:
getNDC in interface INestedDiagnosticContext


getNDCDepth

public int getNDCDepth()
Get the current nesting depth of this diagnostic context
Specified by:
getNDCDepth in interface INestedDiagnosticContext


inheritNDC

public void inheritNDC(java.util.Stack stack)
Inherit the diagnostic context of another thread.
Specified by:
inheritNDC in interface INestedDiagnosticContext


popNDC

public void popNDC()
Clients should call this method before leaving a diagnostic context.
Specified by:
popNDC in interface INestedDiagnosticContext


pushNDC

public void pushNDC(java.lang.String message)
Push new diagnostic context information for the current thread.
Specified by:
pushNDC in interface INestedDiagnosticContext


removeNDC

public void removeNDC()
Remove the diagnostic context for this thread
Specified by:
removeNDC in interface INestedDiagnosticContext


setNDCMaxDepth

public void setNDCMaxDepth(int depth)
Set maximum depth of this diagnostic context.
Specified by:
setNDCMaxDepth in interface INestedDiagnosticContext


toString

public java.lang.String toString()

Returns:
a String representation of my current state
Overrides:
toString in class java.lang.Object

getCategoryInfo

protected java.lang.String getCategoryInfo(org.apache.log4j.Category c)


dumpCategories

public static void dumpCategories()
This method will print the configuration for all Categories in the current default hierarchy. It prints each category name, priority, and a list of all appenders by name.


WebLogic Integration

WebLogic Integration (WLI)