Custom Log Categories

Salesforce B2C Commerce logging supports log categories in a way that is similar to Log4J2 (a Java-based logging utility supported by Apache Software Foundation). A log category is basically a name, where a dot in the name is interpreted as a hierarchical structure. For example, the log category "product.import" would be a subcategory of "product". All categories are subcategories of a "root" category.

B2C Commerce's category rules are:

Examples:

If... Then...
Logging is enabled for "product" It's also enabled for "product.import"
logging is enabled for the root logger It's enabled for all custom log categories
WARN logging is enabled for "product" WARN and ERROR is logged for "product" and all its subcategories
WARN logging is enabled for "product" and DEBUG for "product.import" WARN and ERROR is logged for "product" and all its subcategories, for the subcategory "product.import" also DEBUG and INFO is logged.

See Configuring Custom Logging Categories.

Example: :

function sendOrder() {
   var logger = Logger.getLogger( "order.send" );
   ...
   logger.debug( "Sending order #{}", order.getOrderNumber() );
   ...
}

NDC Support

With Nested Diagnostic Context (NDC), the application can provide additional context information, which is associated with the current running thread. A simple string can be provided as NDC, which is organized like a stack. Both the NDC and log category are reported as a standard element of the actual log message. This is an example of how this feature is used:

function process() {
   Log.getNDC().push( "order.processing" );
   try
   {
      ...
   }
   finally
   {
      Log.getNDC().pop();
   }
}

Message Format

Message formatting supports a simple '{}' for inserting an argument. The method is tolerant if more argument placeholders are provided then arguments exist. In that case, the placeholder isn't replaced but remains a '{}'.

For backwards compatibility, B2C Commerce also supports Java message formatting.

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.