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 level | Levels logged |
|---|---|
| Debug | Debug, Info, Warn, Error, Fatal |
| Info | Info, Warn, Error, Fatal |
| Warn | Warn, Error, Fatal |
| Error | Error, Fatal |
| OFF | None, 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.