b2c-logging

Implement structured logging in B2C Commerce scripts using Logger and Log APIs.

51|16|Updated Oct 31, 2025
One-click install
npx skills add https://github.com/SalesforceCommerceCloud/b2c-developer-tooling --skill b2c-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: b2c-logging
Source: https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/tree/main/skills/b2c/skills/b2c-logging
Command: npx skills add https://github.com/SalesforceCommerceCloud/b2c-developer-tooling --skill b2c-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables developers to implement structured logging in B2C Commerce scripts using the Logger and Log APIs, providing observability and easier debugging.

Core Features & Use Cases

  • Static and instance logging using Logger and Log
  • Category-based logging with getLogger for modular logs
  • Custom named log files via Logger.getLogger(prefix, category)
  • Nested Diagnostic Context (NDC) tracing to correlate messages across a request
  • Business Manager integration for configuring log levels per category

Quick Start

Instrument a script by getting a logger for a category (e.g., 'checkout') and logging an informational message such as 'Checkout started'.

Frequently Asked Questions about b2c-logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement structured logging in B2C Commerce scripts?

You can implement structured logging in B2C Commerce scripts using the dw/system Logger and Log APIs. Get a logger for a specific category like 'checkout' and log messages at appropriate log levels to improve observability and troubleshooting.

Can I create custom named log files for my B2C Commerce SFRA controllers?

Yes, you can create custom named log files in B2C Commerce by using the Logger.getLogger(prefix, category) method. This allows you to route logs to specific files for easier debugging and modular log management across transactions.

How does category-based logging work in Salesforce Commerce Cloud?

Category-based logging uses getLogger to assign log messages to modular categories. You can configure log levels per category directly within Business Manager, giving you granular control over log output without changing server-side code.

What is NDC tracing and how do I use it for B2C Commerce checkout debugging?

Nested Diagnostic Context (NDC) tracing correlates log messages across a single request in B2C Commerce. Use the dw/system logging APIs to push context information, helping you trace the flow of transactions like checkout and order processing.

Does B2C Commerce support both static and instance logging methods?

Yes, B2C Commerce supports both static and instance logging. The dw/system Logger and Log APIs allow you to call logging methods statically or instantiate loggers, providing flexibility for different server-side scripting requirements.