MethodInterceptor implementation for tracing.
By default, log messages are written to the log for the interceptor class,
not the class which is being intercepted. Setting the useDynamicLogger
bean property to true causes all log messages to be written to
the Log for the target class being intercepted.
Subclasses must implement the invokeUnderTrace method, which
is invoked by this class ONLY when a particular invocation SHOULD be traced.
Subclasses should write to the Log instance provided.
setUseDynamicLogger, invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
| Modifier and Type | Field and Description |
|---|---|
| protected transient Log | defaultLogger
The default |
| private boolean | hideProxyClassNames
Indicates whether proxy class names should be hidden when using dynamic loggers. |
| private boolean | logExceptionStackTrace
Indicates whether to pass an exception to the logger. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Class | Returns: the target class for the given objectthe target object to introspect target)Determine the class to use for logging purposes. |
| protected Log | Returns: theLog instance to usethe invocation)MethodInvocation being tracedReturn the appropriate |
| public Object | invoke(MethodInvocation
the method invocation joinpoint invocation)Implements org. MethodInvocation.
|
| protected abstract Object | Returns: the result of the call toMethodInvocation.proceed()the logger)Log to write trace messages toSubclasses must override this method to perform any tracing around the
supplied |
| protected boolean | isInterceptorEnabled(MethodInvocation
the invocation, Log MethodInvocation being tracedthe logger)Log instance to checkDetermine whether the interceptor should kick in, that is,
whether the |
| protected boolean | isLogEnabled(Log
the logger)Log instance to checkDetermine whether the given |
| public void | setHideProxyClassNames(boolean hideProxyClassNames)
Set to "true" to have |
| public void | setLogExceptionStackTrace(boolean logExceptionStackTrace)
Set whether to pass an exception to the logger, suggesting inclusion of its stack trace into the log. |
| public void | |
| public void | setUseDynamicLogger(boolean useDynamicLogger)
Set whether to use a dynamic logger or a static logger. |
| protected void | writeToLog(Log logger, String message)
Write the supplied trace message to the supplied |
| protected void | writeToLog(Log logger, String message, Throwable ex)
Write the supplied trace message and |
| defaultLogger | back to summary |
|---|---|
| protected transient Log defaultLogger The default | |
| hideProxyClassNames | back to summary |
|---|---|
| private boolean hideProxyClassNames Indicates whether proxy class names should be hidden when using dynamic loggers.
| |
| logExceptionStackTrace | back to summary |
|---|---|
| private boolean logExceptionStackTrace Indicates whether to pass an exception to the logger.
| |
| AbstractTraceInterceptor | back to summary |
|---|---|
| public AbstractTraceInterceptor() | |
| getClassForLogging | back to summary |
|---|---|
| protected Class Determine the class to use for logging purposes.
| |
| getLoggerForInvocation | back to summary |
|---|---|
| protected Log getLoggerForInvocation(MethodInvocation invocation) Return the appropriate
| |
| invoke | back to summary |
|---|---|
| public Object invoke(MethodInvocation invocation) throws Throwable Implements org. Determines whether logging is enabled for the particular
| |
| invokeUnderTrace | back to summary |
|---|---|
| protected abstract Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable Subclasses must override this method to perform any tracing around the
supplied By default, the passed-in
| |
| isInterceptorEnabled | back to summary |
|---|---|
| protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger) Determine whether the interceptor should kick in, that is,
whether the Default behavior is to check whether the given
| |
| isLogEnabled | back to summary |
|---|---|
| protected boolean isLogEnabled(Log logger) Determine whether the given Default is
| |
| setHideProxyClassNames | back to summary |
|---|---|
| public void setHideProxyClassNames(boolean hideProxyClassNames) Set to "true" to have | |
| setLogExceptionStackTrace | back to summary |
|---|---|
| public void setLogExceptionStackTrace(boolean logExceptionStackTrace) Set whether to pass an exception to the logger, suggesting inclusion of its stack trace into the log. Default is "true"; set this to "false" in order to reduce the log output to just the trace message (which may include the exception class name and exception message, if applicable).
| |
| setLoggerName | back to summary |
|---|---|
| public void setLoggerName(String loggerName) Set the name of the logger to use. The name will be passed to the underlying logger implementation through Commons Logging, getting interpreted as log category according to the logger's configuration. This can be specified to not log into the category of a class (whether this interceptor's class or the class getting called) but rather into a specific named category. Note Specify either this property or "useDynamicLogger", not both. | |
| setUseDynamicLogger | back to summary |
|---|---|
| public void setUseDynamicLogger(boolean useDynamicLogger) Set whether to use a dynamic logger or a static logger. Default is a static logger for this trace interceptor. Used to determine which Note Specify either this property or "loggerName", not both. | |
| writeToLog | back to summary |
|---|---|
| protected void writeToLog(Log logger, String message) Write the supplied trace message to the supplied To be called by Delegates to
| |
| writeToLog | back to summary |
|---|---|
| protected void writeToLog(Log logger, String message, Throwable ex) Write the supplied trace message and To be called by By default messages are written at
| |