Configure Custom Log Categories

Using log category-specific filters, you can decide which messages are made available to log targets. The filter rules enable you to define which log messages are generated. The changes you make become active once you click Save.

The hierarchy of logging levels in B2C Commerce is Fatal, Error, Warn, Info, and Debug. You can create your own categories of messages that are specific to the scripts you are developing.

Note: System log messages are not configurable.

We recommend that you plan a simple hierarchy of logging messages before creating logging categories. For example, you might want to plan category names that include the script name, object, and method as a standard. Having a standard set of logging names can make code maintenance easier.

B2C Commerce's custom logging is modeled after log4j logging. Logging uses hierarchical category names, granular logging, and similar methods for creating log statements in your code. For example, if you create three logging categories: product, product.import, and product.feed, product is considered the ancestor category and, if enabled, includes all messages logged to product.import and product.feed. The two descendant categories, if enabled, log only those messages assigned to them. You can control the granularity of logging by enabling or disabling categories.

The root filter rule is always present. It defines the base level for all custom logs (corresponds to β€˜ALL’ in the old configuration). You can disable custom logging by setting the root level to OFF. If the filters contain just the root rule, all the custom logs are filtered by this rule. The defined level is the minimum level. If Info is set, then all the levels above Info are also generated (Warn, Error, Fatal).

Note: To prevent excessive log size, maximum size of SOAP-related log messages in the custom debug log is 20,000 characters.
  1. Select Administration > Operations > Custom Log Settings.
  2. On the Custom Log Settings page, you can configure custom log setting filters:
    1. Enter a log category name.
      Note: Custom log category names can’t include β€œcustom” as a prefix.

      For each category, you can define a special logging rule. The level that you set on this rule applies to the defined category and to the subcategories of that category. The category rule is considered first, and then the root rule. Only one rule can be defined per category. You can disable a rule by unchecking the active checkbox of that rule. All is a reserved category name and can't be used in category rules.

    2. Select the Log Level.

      If you set the log to OFF, no log messages for that category are logged, not even Fatal.

      You can't configure the Debug level on a Production instance.
    3. Click Add.
      The log category appears in the list.
    4. To enable a specific category, check the Active box.
    5. To delete a log category, click the trash icon beside it.
      You can't delete the root log category.
  3. In the Custom Log Targets section:
    Only the messages that pass the filters are available for the log targets.
    1. Enter an email address for Fatal messages.

      One email is sent per minute. Messages with a Fatal log level can be sent to email recipients. You can enter a maximum of 1000 characters for all email addresses.

    2. Select the log levels that are written to the files:

      Different log files are created for each log level. The exception is that when log messages are written using a developer-provided file prefix, all messages for that log category are written to the same file, regardless of the log level.

      Custom log files are constrained to 10 MB per day.

      The Debug log level can't be enabled on a Production instance.

    3. View log messages in a log search web application, such as Log Center.
      There is a limit to number of log messages per realm per day that can be viewed in Log Center. A message appears when the limit is exceeded.
    4. View log messages using the Request Log Viewer in the Storefront Toolkit on instances other than Development and Production.
  4. Click Save to save your changes.

Sample Configurations

The following examples show how log messaging is enabled and disabled using settings that take advantage of the log hierarchy:

Configuration Active Category Level Generated logs
1

-

yes

root

category1

WARN

INFO

category1: INFO, WARN, ERROR, FATAL

category1.subcategory: INFO, WARN, ERROR, FATAL

other custom categories: WARN, ERROR, FATAL

2

-

no

root

category1

WARN

INFO

category1: WARN, ERROR, FATAL

category1.subcategory: WARN, ERROR, FATAL

other custom categories: WARN, ERROR, FATAL

3

-

yes

root

category1

OFF

INFO

category1: INFO, WARN, ERROR, FATAL

category1.subcategory: INFO, WARN, ERROR, FATAL

other custom categories: no logs

4

-

yes

root

category1

WARN

ERROR

category1: ERROR, FATAL

category1.subcategory: ERROR, FATAL

other custom categories: WARN, ERROR, FATAL

5

-

yes

root

category1

WARN

OFF

category1: no logs

category1.subcategory: no logs

other custom categories: WARN, ERROR, FATAL

6

-

yes

yes

root

category1

category1.subcategory

WARN

INFO

DEBUG

category1: INFO, WARN, ERROR, FATAL

category1.subcategory: DEBUG, INFO, WARN, ERROR, FATAL

other custom categories: WARN, ERROR, FATAL