Debug Your Storefront Next Site Using Log Center

Use Log Center to debug production issues for sites built using Storefront Next. Log Center aggregates logs from Managed Runtime (MRT) and your B2C Commerce instance in one place.

Log Center:

  • Provides a single location to access logs from MRT and your B2C Commerce instance, so you can connect what’s happening in your MRT environment with what’s going on in your B2C Commerce instance.
  • Lists Shopper Login and API Access (SLAS) errors. See View SLAS Error Logs in Log Center.
  • Displays CDN error logs (status code 5xx), which help you troubleshoot content delivery and performance issues.
  • Lets you search and filter many historical logs, so you can investigate and resolve issues faster.
  • MRT logs in Log Center are available for any environment with Log Center logs enabled and a B2C Commerce instance associated. Marking the environment as production isn’t required. See Prerequisites.
  • There can be a delay of up to 15 minutes between the time that an event happens and the log appears in Log Center.

Note

For information about the Storefront Next structured logger and log levels, see Logging in Storefront Next.

Log Center Prerequisites 

To access MRT logs for an environment in Log Center, first:

  1. Have the Log Center User role in Account Manager. To verify, check your role in Account Manager. If you don’t have the role, ask your Account Manager admin to give you access. See Managing Account Manager for Salesforce B2C Commerce Users.

  2. Create an environment. See Create an Environment in Business Manager.

    Creating an environment in Business Manager associates the B2C Commerce instance and site IDs to the environment, which are prerequisites for Log Center logging.

  3. Enable Log Center logs and Log Center metrics under Observability in Environment Settings. [DOUBLE CHECK THIS]

View Logs 

After you complete the Prerequisites, to view MRT logs in Log Center:

  1. Open Log Center.

  2. Select a Region.

  3. Select a Realm. If you don’t know your realm ID, ask your Salesforce account executive (AE) or customer success manager (CSM).

  4. Click Show filtered results.

  5. Click Search > Current Search.

  6. Under Service Type, select mrt for Managed Runtime logs.

  7. Under Request Type, select SSR for application logs or CDN for CDN logs.

  8. Under Host, select the environment whose logs you want to see. The format of the host is $PROJECT.$ENVIRONMENT. If you have more than one MRT environment with Log Center logs enabled, you see multiple MRT host names.

  9. View the MRT logs.

    Storefront Next emits logs in structured JSON format—one JSON object per line. Each line includes these fields.

    FieldDescription
    levelLog severity: error, warn, info, or debug.
    msgThe log message.
    correlationIdA unique ID assigned per request. All log entries for a single request share the same correlationId, so you can trace a request end to end.
    methodThe HTTP method, for example, GET or POST.
    pathThe URL pathname of the request.

    For example:

    1{
    2  "level": "warn",
    3  "correlationId": "a1b2c3",
    4  "method": "GET",
    5  "path": "/product/25518447M",
    6  "msg": "Product not found"
    7}

    To narrow results to a specific request, filter on correlationId. To narrow results to a specific route, filter on path or method.

    The log level defaults to warn in production and info in other environments. The SFCC_LOG_LEVEL environment variable controls the log level. If you don’t see expected log entries, check that the log level for your environment is set appropriately. See Configure the Log Level.

    Note

  10. (Optional) Generate logs for a specific component or third-party integration by using a custom field to make log filtering easier. Log Center lets you filter on the custom field to find all logs from a specific area of your codebase.

    For server-side code in loaders, actions, or middleware, use getLogger(context). In this example, the custom field in the log call is component.

    1import { getLogger } from "@/lib/logger.server";
    2
    3export async function loader({ context }: LoaderFunctionArgs) {
    4  const logger = getLogger(context);
    5  if (err.code === "MISSING_DESCRIPTION") {
    6    logger.warn("Missing description", {
    7      component: "CmsProductDescription",
    8      errorCode: err.code,
    9    });
    10  }
    11}

    For module-scope or client-side code where router context isn’t available, use createLogger():

    1import { createLogger } from "@/lib/logger";
    2
    3const logger = createLogger({ component: "CmsProductDescription" });
    4logger.warn("Missing description", { errorCode: err.code });

    In both cases, the component field, or any custom field you add, appears in every log line and is searchable in Log Center.

Limitations 

  • Managed Runtime: Each MRT log message available when you tail logs or use Log Center is limited to 32 KB. Characters over 32 KB are truncated. To avoid truncated messages, tail logs in a non-production environment and shorten any long messages. See Tail Logs in the B2C Developer Toolkit.
  • Log Center: For information about log levels and log volumes, see Configuration for Administrators.

See Also