Web Service Logging and Troubleshooting
You can view generated logs by navigating in Business Manager to
and clicking the link for Log files.The log file name for a web service always starts with "service" then the log prefix
set in the web service profile, and then internal information. For example:
service-logprefix-blade2-4-appserver-20150206.log.
service.serviceName.type
- head: After every service call, logs a message indicating success or failure.
-
comm: After every service call, logs data passed to the underlying transport and the response received from it. Communication logs are disabled by default and log at the INFO level when enabled. This means in order to see communication logs, a service must have its Communication Log Enabled box checked and its log level must be
info
ordebug
.The comm logging is filtered to prevent sensitive data from being accidentally logged on a Production instance. The logging of filtered data is possible, but only by enabling communication logging for the service and also applying the
filterLogMessage
function or applying both thegetRequestLogMessage
andgetResponseLogMessage
functions in the service initialization. Importing a service definition with communication logging enabled on a Production system doesn't enable this logging and throws a warning message in the import log indicating that communication logging is disabled. This is a fail-safe to prevent accidentally enabling communication logging that could contain sensitive data. You can force non-production instances to behave like production instances by checking the Force PRD behavior in non-PRD environments box. - log: Logs miscellaneous messages, such as service initialization and error traces
mycartridge.http.payment.list
,
mycartridge.http.payment.get
, and
mycartridge.ftp.getPriceList
; this creates the following logging
structure:
service
.mycartridge
.ftp
.getPriceList
.comm
.head
.log
.http
.payment
.get
.comm
.head
.log
.list
.comm
.head
.log
Setting Log Levels
Log levels are adjusted in
.For example: for the services described above, you might create the following log categories.
Warn
Enable | Log Category |
---|---|
services | |
✔ | mycartridge.service.ftp |
Info
Enable | Log Category |
---|---|
mycartridge.service.http.payment | |
✔ | mycartridge.service.http.payment.list |
Debug
Enable | Log Category |
---|---|
✔ | mycartridge.service.http.payment.get |
✔ | mycartridge.service.http.payment.list.log |
services.ftp
category is set to the
warning
log level, so comm
logs are not generated for the
mycartridge.ftp.getPriceList
service. The
mycartridge.http.payment.get
category generates head
,
comm
, and log
logs with debug
level
logging. The mycartridge.http.payment.list
category generates
head
and comm
logs with info
level
logging and a log
log with debug
level logging.Filtering Logs
You might need to filter sensitive or private data, such as credit card numbers, so that it's not logged. You can do this in two ways:
Example 1: Filter a System-Provided Log Message
This
example shows how to add a filterLogMessage
callback to the service
definition to filter log
messages.
ServiceRegistry.configure("my.service", {
createRequest: ...,
parseResponse: ...,
filterLogMessage: function(msg:String): {
return msg.replace(/CreditCardNo\: \".*?\"/, "CreditCardNo:********");
}
});
Example 2: let the ServiceCallback
provide the
log message
This example shows how to capture log messages using
getRequestLogMessage
, convert them to log messages and filter or edit
them.
ServiceRegistry.configure("my.service", {
createRequest: ...,
parseResponse: ...,
getRequestLogMessage: function(reqObj:Object): {
// Convert to a String here, doing any filtering...
return msg;
},
getResponseLogMessage: function(respObj:Object): {
// Convert to a String here, doing any filtering...
return msg;
}
});
Web service response Examples
This section shows typical responses from a simple web service.
Using HTTPResult as an example (all other result objects for other service types follow the same schema):
for a Simple HTTP GET Request That Was Successful, You Get Back:
[ error=0, errorMessage=null, mockResult=false, msg=OK, object=<html>…</html>, ok=true, status=OK ]
for a Simple HTTP GET Request That Failed, You Get Back:
[ error=500, errorMessage=null, mockResult=false, msg=INTERNAL SERVER ERROR, object=null, ok=false, status=ERROR ]
for a Simple HTTP GET Request That Failed Due to 404, You Get Back:
[ error=404, errorMessage=null, mockResult=false, msg=NOT FOUND, object=null, ok=false, status=ERROR ]
When You Hit the Rate Limit, You Get Back:
[ error=0, errorMessage=Rate Limit Exceeded, mockResult=false, msg=null, object=null, ok=false, status=SERVICE_UNAVAILABLE ]
When You Hit the Circuit Breaker, You Get Back:
[ error=0, errorMessage=Failure Count Exceeded, mockResult=false, msg=null, object=null, ok=false, status=SERVICE_UNAVAILABLE ]
When You Hit the Timeout, You Get Back:
[ error=0, errorMessage=SocketTimeoutException:Read timed out, mockResult=false, msg=Read timed out, object=null, ok=false, status=SERVICE_UNAVAILABLE ]
Troubleshooting Web Services
- make sure the cartridge containing your script is in the cartridge path.
- make sure that the web service is enabled.
- make sure that the web service is set to Live and not Mocked.
In UX Studio:
- make sure that you point to your initialization script in your package.json.
- make sure that your initialization script has a service definition for your web service.
- make sure that your service definition includes callback objects that handle the web service response.
- make sure that you have written a script that calls your web service
- Make sure that your web service is available.