Overview
The service solves a simple problem - when a customer complains that something is broken quite often the logfile is not enough - a glimpse at the parameters being used for the service invocation would help a great deal. Therefore this interceptor is intended for running in the background and dumping all parameters when an exception occurs.
Filtering using the Logger
The service implementation uses the trace level of its logger to control the generated output. E.g. setting the tracelevel to INFO would result in tracing method invocations and exceptions but would ignore the results from the mehtod invocation.
Trace Level | Description |
---|---|
ERROR | Dumps the context information for an onError invocation |
INFO | Dumps the context information for an onEntry invocation |
DEBUG | Dumps the context information for an onExit invocation |
Captured Information
During the execution the service captures the following information for producing a meaning log
Item | Description |
---|---|
Transaction ID (TID) | the number of times the invocationDepth was zero |
Invocation ID (IID) | the current number of inovking a service method |
InvocationDepth (ID) | the service invocation depth, e.g a value of "1" that the currently invoked service method was invoked by another service. A value of "0" indicates that the service method was directly invoked from the caller therefore starting a new transaction |
Mode (M) |
the invocation mode of the interceptor
|
ServiceName | the shorthand of the service being invoked |
ServiceMethod | the name of the service method being invoked |
Millis | the execution time in milliseconds |
Method Signature | the name of the executing thread |
Parameters | the list of parameter values |
Exception | the class of the exception being caught |
Stacktrace | the stacktrace of the exception being caught |
Example Logfile
Looking at the following example you see that
- that this was the 54th transaction during the lifetime of the container
- PdfSignatureService.sign wa invoked with the seven parameter values as shown below
- an invalid PDF document caused a SignatureServiceException
- SignatureService.sign was the caller of PdfSignatureService.sign and just rethrow the exception.
TID IID ID M Service Method Signature 54 402 1 2 PdfSignatureService sign Object service.signature.SignatureService.sign( String,String,String,Object,String,String,Hashtable) arg[0]:={SUPPLIER} arg[1]:={SUPPLIER} arg[2]:={de} arg[3]:={[B@36d047} arg[4]:={broken.pdf} arg[5]:={application/pdf} arg[6]:={{isPdfAttached=false}} service.signature.SignatureServiceException Rebuild failed: trailer not found 54 400 0 2 SignatureService sign service.signature.SignatureService.sign( String,String,String,Object,String,String,Hashtable) arg[0]:={SUPPLIER} arg[1]:={SUPPLIER} arg[2]:={de} arg[3]:={[B@36d047} arg[4]:={broken.pdf} arg[5]:={application/pdf} arg[6]:={{isPdfAttached=false}} service.signature.SignatureServiceException Rebuild failed: trailer not found
Configuration
Component Configuration
Item | Datatype | Cardinality | Description |
---|---|---|---|
isEnabled | Boolean | [0|1] | Turn the interceptor. If no value is supplied then "false" is used thereby disabling all interceptor invocations. |
maxArgLength | Integer | [0|1] | The maximum length of an method argument to avoid dumping megabytes of data into the logfile. |
toStringBuilderClass | String | [0|1] | The class name of the string builder to use to format the method parematers and the result. If no value is supplied the SmartToStringBuilder is used. |
monitorAllExceptions | Boolean | [0|1] | Dump all encountered excpetions therefore overriding the list of monitored services. If no value is supplied then "true" is used. |
services | Tree | [0|1] | Contains a list of services to be monitored. |
services/service@name | String | [1..n] | The name of an individual service to be monitored. |
Role Configuration
<role name="org.apache.fulcrum.yaafi.interceptor.logging.LoggingInterceptorService" shorthand="LoggingInterceptorService" default-class="org.apache.fulcrum.yaafi.interceptor.logging.LoggingInterceptorServiceImpl" logger="tracing" />
Log4J Configuration
The following Log4J configuration defines a custom appender for the PerformanceInterceptorService. For the layout we just add a timestamp since we produce a CSV file to be analyzed with EXCEL or your tool of choice
# # Custom logfiles # log4j.category.yaafi.tracing = ERROR, tracing log4j.additivity.yaafi.tracing = false # # Tracing Appender # log4j.appender.tracing = org.apache.log4j.RollingFileAppender log4j.appender.tracing.file = ./temp/tracing.csv log4j.appender.tracing.MaxFileSize=2000KB log4j.appender.tracing.layout=org.apache.log4j.PatternLayout log4j.appender.tracing.layout.conversionPattern=%d;%t;%m%n log4j.appender.tracing.threshold=DEBUG log4j.appender.tracing.append = true
Usage
Dump the method invocation of all services using ReflectionToStringBuilder
<LoggingInterceptorService> <isEnabled>true</isEnabled> <maxArgLength>2000</maxArgLength> <toStringBuilderClass>org.apache.fulcrum.yaafi.interceptor.util.SmartToStringBuilderImpl</toStringBuilderClass> <monitorAllExceptions>true</monitorAllExceptions> <services> <service name="*"/> </services> </LoggingInterceptorService>