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.
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).
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 |