Application Development53% of the exam

Logger API: custom log files and levels

How to write script logging with dw.system.Logger and Log: category loggers versus custom named files, static methods versus logger instances, MessageFormat arguments, enabled-level guards, which level reaches a file, redundancy suppression and keeping sensitive data out of logs.

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

~7 min read · 10 practice questions ·

What the exam expects

  • Obtain a logger for a category or for a custom named log file, and predict which file the messages land in when several scripts use the same prefix.
  • Choose between the static Logger methods and a Log instance, including for fatal messages.
  • Write messages with MessageFormat placeholders and guard expensive debug output with the instance's enabled check.
  • Pick the log level that reaches a file given the existing Custom Log Settings and notification requirements.
  • Explain gaps caused by redundancy suppression, read the custom error log for controller exceptions, and keep sensitive data out of logs, including service communication logs.

Key terms: category (the name a logger is configured by in Custom Log Settings); file name prefix (the first getLogger argument that creates a custom named log file); Log (the log4j-like logger instance the getters return); MessageFormat (the Java {0} placeholder syntax the logging methods implement); redundancy tracking (suppression of error and warn messages repeated too often).

Key facts

Same prefix twice
Detail
Same log instance, same log file
Named file categories
Detail
Business Manager custom log categories also apply
Prefix length
Detail
3 to 25 characters
File name quota
Detail
200 per day per appserver (Web Services page says 40); then getLogger throws
Static methods
Detail
debug, info, warn, error; no static fatal
Fatal
Detail
Always enabled; optional email
Placeholder syntax
Detail
Java MessageFormat, {0}, {1}
customwarn
Detail
Always logged to file
Debug on production
Detail
Always disabled
Redundancy
Detail
Over 10 in 3 minutes: suppressed 3 minutes
Custom error log
Detail
Function hierarchy and line numbers, for developers
Comm log import to production
Detail
Not enabled; warning in the import log
Sources for this section (5)
  • What does Log.getNDC() return?
  • When does a new suppression period start after one has ended?
  • Why can't _renewals be used as a file name prefix?
  • Which three Logger methods return a Log instance?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the B2C Commerce Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the B2C Commerce Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Practice exams purchase adds inline bank questions and topic practice (10 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Choose guide-only, practice-only, or save $4 with both

Practice for the B2C Commerce Developer exam