B2C Commerce ' sLoggermethods support parameterized message formatting. Placeholders such as{0}and{1}are placed in the message string, and the corresponding values are supplied as subsequent arguments to the logging method. Option A therefore correctly logs the product ID and product name.
The Salesforce Script API documentation forLoggerspecifies message formatting based on indexed placeholders and arguments, allowing calls such asLogger.warn(message, args...). This avoids manual concatenation and makes structured log messages easier to read and maintain.
Option B places JavaScript template-literal-style expressions inside an ordinary single-quoted string. Because the value is not enclosed with backticks and the B2C logger does not interpret${...}expressions inside a normal string, those expressions would not be evaluated as intended. Option C is also incorrect:.context()is not a post-processing method used to substitute{0}and{1}after callingwarn().
Parameterized logging is preferable for operational diagnostics because the fixed message pattern remains consistent while dynamic values are inserted at runtime.
Study Guide reference:Application Development —dw.system.Logger, custom logging, message formatting, diagnostic instrumentation, and troubleshooting.
===============
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit