View SCAPI Logs and Track Requests
Log Center provides comprehensive logging and monitoring capabilities for B2C Commerce API (SCAPI) operations. Use Log Center to troubleshoot issues, monitor performance, and analyze API behavior across your B2C Commerce instances.
- Log into Business Manager.
- Click App Launcher
and then select Administration > Site Development > Development Setup. If you built your site using Progressive Web App (PWA) Kit, first complete the prerequisites described in Debug Using Log Center.
For general information on Log Center, see Centralized Log Center.
In Log Center, navigate to Logs > Search.
SCAPI logs appear in Log Center with a delay of up to 5 minutes.
You can use correlation IDs to match a particular request to a particular response, making it easier to troubleshoot unexpected issues, such as internal server errors.
If a correlation-id
header is provided in a request to a SCAPI endpoint, the response contains an correlation-id
header that contains the value of correlation-id
. The API also generates its own correlation ID for each response. This generated ID is provided in the sfdc_correlation_id
response header.
Example headers:
The value of correlation-id
must only contain word characters, hyphens (-) and commas (,). Other characters may prevent from the ability to search for that correlation ID string in Log Center.
For most Commerce API endpoints, the correlation-id
can be automatically added to log messages with a hook. You can query these messages in Log Center with an LCQL (Log Center Query Language) expression that filters messages based on the externalID
field. The externalID
field contains the value of the correlation-id
response header, so you can query for the user-provided correlation ID, the SCAPI-generated correlation ID, or the combined string.
If you can reproduce an issue, you might be able to identify the problem either by attaching your own correlation ID or by observing the automatically generated correlation ID in the response.
You can use this correlation ID to trace specific requests:
- In Log Center search, enter the correlation ID in the search field or use a Log Center Query Language (LCQL) expression on the
externalID
field, for example:externalID:(9527f1869f95a32d)
. - You can filter by relevant service types for a more focused results, which is only recommended if the result set is very large.
Some groups of Commerce API endpoints are not used exclusively with B2C Commerce and therefore can't log requests and responses to Log Center. These API groups include CDN Zones, Inventory Availability, Inventory Impex, Inventory Reservation, Shopper Context, and Shopper Login.
You can also use the SCAPI logs in Log Center to investigate patterns of frequent errors:
- Select the SCAPI category or categories from the dropdown menu.
- Select
scapi-http
to identify requests with specific error response codes. - Select
scapi
to find error messages about how the SCAPI requests are processed, for example: incorrect requests, failing authentication, or routing issues.
- Select
- Execute a search to identify error status types that occur.
- To dig deeper into a specific error, obtain one or multiple correlation IDs from the results and search for further entries with the same correlation ID. For details, see Investigating By Correlation ID.
With B2C Commerce version 24.7, you can generate a JSON document that contains comprehensive information about the request. This JSON document is beneficial for troubleshooting, because it provides detailed information that is not included with standard logging, such as request authorization, hook execution, request query parameters, headers, and body.
To mitigate potential performance issues, the usage of the header is subject to rate limiting. Headers should only be used for individual test requests when a detailed investigation is necessary.
To enable this feature, include the following header in your request:
- Header:
sfdc_verbose: true
Upon the completion of the request, a JSON document is created and logged within the INFO log associated with the correlation ID of that request.
In combination with the correlation-id
, the sfdc_verbose
header can be used to generate and find verbose log output in the Log Center.
- Log into Log Center as described in Start Log Center.
- Use the correlation ID or the category
scapi.verbose
in combination with the Log Center Search to find the corresponding log entry.
The following example shows the objects (auth
, request
, response
, customApi
, hooks
) that can be present in a verbose log entry:
You can view SCAPI and SCAPI hook metrics in the Metrics Dashboard. To view the metrics, click Metrics in Log Center, and then click SCAPI or SCAPI Hooks. See Metrics Dashboard.
Additional SCAPI metrics are provided in the CCAC SCAPI Dashboard
For additional details, see Log Center Metrics Documentation.