Cert++
Close

Choosing the log level for a script log message

Key Takeaway

A message is logged only when its level is at or above its category's minimum level, and Debug can't be enabled on Production. So a message needed on Production must use Info or higher. A message you may want to switch off later must use a level below the minimum that will stop it.

In B2C Commerce scripts, you log a message by calling a level method on a dw.system.Log object for a named log category. The level methods are debug(), info(), warn(), error() and fatal(). Each category has a minimum level set in Business Manager. The level you choose decides whether the message is logged at all, and it can also decide which file the message goes to.

Log levels and the minimum level

B2C Commerce has five log levels. From highest to lowest severity, they are Fatal, Error, Warn, Info and Debug.

Each category has a minimum level. Enabling a level also enables every higher level, so a message is logged only when its level is at or above the category's minimum.

Minimum levelLevels logged
DebugDebug, Info, Warn, Error, Fatal
InfoInfo, Warn, Error, Fatal
WarnWarn, Error, Fatal
ErrorError, Fatal
OFFNone, not even Fatal

The Debug level can't be enabled on a Production instance, so debug() messages aren't logged there. A message you need to see on Production must use Info or a higher level.

Fatal messages are always enabled. Setting a category's level to OFF, however, logs nothing for that category, not even Fatal.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a logging task and existing configuration, write code that logs non-sensitive data to custom log files with different log levels

0/4

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.