Custom error logs versus system error logs for controller exceptions
Key Takeaway
To find where a controller or script exception was thrown, look in the custom error log (customerror_* files), because it shows the function chain and the line numbers. Use try/catch to handle a failing call, and use Logger.error to record the details in that same log.
B2C Commerce writes controller and script exceptions to log files, and two error logs hold them. The custom error log is the one built for developers, because it points to the functions and lines behind a failure. The system error log holds Java-related errors and is mainly used by B2C Commerce Support. When a controller fails, you need to know which log to open and how to write your own entries into it.
Two types of logging
B2C Commerce has two types of logging. System logging is on by default. Only Salesforce Support can change its configuration. Custom logging covers programmatic logging from script files. You configure custom logging in Business Manager.
When a controller or script throws an exception, B2C Commerce writes it to log files. Two error logs matter here:
| Custom error log | System error log | |
|---|---|---|
| Files | customerror_* | error_* |
| What it holds | Almost any JavaScript-related error, including errors from B2C Commerce scripts and controllers | Java-related errors on B2C Commerce |
| Who it's for | Developers | Primarily B2C Commerce Support |
Almost any JavaScript-related error lands in the custom error log, so it is the first place to look when a controller fails. The system error log is usually less useful to developers outside Salesforce.