| | |
|
|
|
Simple logging connection handlers
Two logging connection handlers are included with the connection infrastructure. These are designed for simple scenarios and as an aid to problem determination when using the Connection API to work with a remote service.
- SimpleJavaLoggerHandler
- Writes values read from the GlobalContext using the Java logging API.
- SimpleDestinationLoggerHandler
- Sends values read from the GlobalContext to a destination using the
POST operation of the Connection API.
Configuration and usage
The deployment and configuration requirements of the simple loggers are similar to each other, the differences being related to the configuration of where the logging information should be sent to.
SimpleJavaLoggerHandler
When configured, SimpleJavaLoggerHandler writes a log entry corresponding to each onRequest() and onResponse() invocation using the Java logging API. The contents of the log entry is controlled by the configuration supplied to SimpleJavaLoggerHandler and may include the values of one or more GlobalContext keys. The log message text represents these as a human-readable set of name-value pairs, using toString().
The following example demonstrates the configuration for the SimpleJavaLoggerHandler:
/config/connection/destinations += [{
"name" : "http:///www.projectzero.org/*",
"handlers" : [{
"class" : "zero.core.connection.handlers.logger.SimpleJavaLoggerHandler",
"config" : {
"logger" : "mylogger",
"source" : "mySource",
"level" : "INFO",
"request" : {
"method" : "myMethodName"
"keys" : ["/connection/request/target","/connection/request/operation"]
}
"response" : {
"method" : "myMethodName"
"keys" : ["/connection/response/body"]
}
}
}]
}]
- logger (optional)
- The name of the
java.util.logging.Logger to be written to. The logger name will be used as an argument to Logger.getLogger(logger). The default value is zero.core.connection.handlers.logger.SimpleJavaLoggerHandler.
- source (optional)
- Name to be used as the source class for logging. The default value is
zero.core.connection.handlers.logger.SimpleJavaLoggerHandler.
- level (optional)
- The logging
Level to be used for logging. The default value is INFO.
- request (optional)
- Specifies configuration for request message log:
-
- method (optional)
- Method name to be used when logging request. The default value is
request.
-
- keys (optional)
- List of GlobalContext keys to be logged for request. The default value a list containing the single value,
/connection/request/body.
- response (optional)
- Specifies configuration for response message log:
-
- method (optional)
- Method name to be used when logging response. The default value is
response.
-
- keys (optional)
- List of GlobalContext keys to be logged for response. The default value a list containing the single value,
/connection/response/body.
For more information about connection destination processing and configuration, see Configuring destinations. For a description of connection handler configuration, see Configuring connection handlers.
SimpleDestinationLoggerHandler
When configured, SimpleDestinationLoggerHandler POST a message corresponding to each onRequest() and onResponse() invocation using the Connection API. The log destination and contents of the message are controlled by the configuration supplied to SimpleDestinationLoggerHandler and may include the values of one or more GlobalContext keys.
The message body contains a Map of GlobalContext key to value Object. The representation of this Map received by the log destination will depend on the configuration of connection handlers for the log destination and the protocol used. For example, the default representation of the message sent using the http protocol will be a human-readable set of name-value pairs, using toString().
The SimpleDestinationLoggerHandler does not guarantee that every request or response passing through the destination will be successfully logged. If the SimpleDestinationLoggerHandler is unable to complete the POST to the log destination the processing of the request or response will continue without a corresponding entry being placed in the log.
The following example demonstrates the configuration for the SimpleDestinationLoggerHandler:
/config/connection/destinations += [{
"name" : "http:///www.projectzero.org/*",
"handlers" : [{
"class" : "zero.core.connection.handlers.logger.SimpleDestinationLoggerHandler",
"config" : {
"destination" : "http://localhost:8080/loggerservice"
"request" : {
"keys" : ["/connection/request/target","/connection/request/operation"]
}
"response" : {
"keys" : ["/connection/response/body"]
}
}
}]
}]
- destination (required)
- Specifies the target resource name for the log destination. This may be any connection destination using a protocol that supports the
POST operation and is able to accept Map request bodies. Examples include HTTP and SMTP.
- request (optional)
- Specifies configuration for request message log:
-
- keys (optional)
- List of GlobalContext keys to be logged for request. The default value a list containing the single value,
/connection/request/body.
- response (optional)
- Specifies configuration for response message log:
-
- keys (optional)
- List of GlobalContext keys to be logged for response. The default value a list containing the single value,
/connection/response/body.
For more information about connection destination processing and configuration, see Configuring destinations. For a description of connection handler configuration, see Configuring connection handlers.
|
|
r7 - 02 Feb 2008 - 09:03:10 - rushall
|
|
|
| | |