b2c-logging
БесплатноБез исполняемых скриптовНе проверенImplement server-side logging with dw.system.Logger, custom log categories, and named log files. Use this skill whenever the user needs to add debug or error…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
Logging Skill
This skill guides you through implementing logging in B2C Commerce using the Logger and Log classes.
Overview
B2C Commerce provides a logging framework with:
| Feature | Description |
|---|---|
| Log Levels | debug, info, warn, error, fatal |
| Categories | Organize logs by functional area |
| Custom Files | Write to dedicated log files |
| NDC | Nested Diagnostic Context for tracing |
| BM Configuration | Enable/disable levels per category |
Log Levels
| Level | Method | Description | Default State |
|---|---|---|---|
debug |
debug() |
Detailed debugging information | Disabled (never on production) |
info |
info() |
General information | Disabled by default |
warn |
warn() |
Warning conditions | Always enabled |
error |
error() |
Error conditions | Always enabled |
fatal |
fatal() |
Critical failures | Always enabled, can send email |
Basic Logging
Using Logger (Static Methods)
The Logger class provides static methods for quick logging:
var Logger = require('dw/system/Logger');
// Simple messages
Logger.debug('Debug message');
Logger.info('Info message');
Logger.warn('Warning message');
Logger.error('Error message');
// Messages with parameters (Java MessageFormat syntax)
Logger.info('Processing order {0} for customer {1}', orderNo, customerEmail);
Logger.error('Failed to process {0}: {1}', productId, errorMessage);
Using Log (Instance Methods)
The Log class provides instance-based logging with categories:
var Logger = require('dw/system/Logger');
// Get logger for a category
var log = Logger.getLogger('checkout');
log.debug('Cart contents: {0}', JSON.stringify(cart));
log.info('Checkout started for basket {0}', basketId);
log.warn('Inventory low for product {0}', productId);
log.error('Payment failed: {0}', errorMessage);
log.fatal('Critical checkout failure: {0}', errorMessage);
Categories
Categories help organize and filter log messages:
var Logger = require('dw/system/Logger');
// Different categories for different areas
var checkoutLog = Logger.getLogger('checkout');
var paymentLog = Logger.getLogger('payment');
var inventoryLog = Logger.getLogger('inventory');
var integrationLog = Logger.getLogger('integration');
// Use appropriate logger
checkoutLog.info('Order {0} submitted', orderNo);
paymentLog.info('Payment authorized: {0}', transactionId);
inventoryLog.warn('Stock level below threshold for {0}', productId);
integrationLog.error('API call failed: {0}', serviceName);
Categories are configured in Business Manager under Administration > Operations > Custom Log Settings.
Custom Named Log Files
Write to dedicated log files instead of the standard custom log files:
var Logger = require('dw/system/Logger');
// Get logger with custom file prefix
var orderExportLog = Logger.getLogger('orderexport', 'export');
var feedLog = Logger.getLogger('productfeed', 'feed');
// Messages go to custom-orderexport-*.log
orderExportLog.info('Exporting order {0}', orderNo);
// Messages go to custom-productfeed-*.log
feedLog.info('Processing product {0}', productId);
File Name Rules
The fileNamePrefix parameter must follow these rules:
| Rule | Requirement |
|---|---|
| Length | 3-25 characters |
| Characters | a-z, A-Z, 0-9, -, _ |
| Start/End | Must start and end with alphanumeric |
| Not allowed | Cannot start or end with - or _ |
File Naming Pattern
Custom log files follow this pattern:
custom-<prefix>-<hostname>-appserver-<date>.log
Example: custom-orderexport-blade0-1-appserver-20240115.log
Quota
Maximum 200 different log file names per day per appserver.
Checking Log Level Status
Check if a log level is enabled before expensive operations:
var Logger = require('dw/system/Logger');
var log = Logger.getLogger('myCategory');
// Check before expensive string building
if (log.isDebugEnabled()) {
log.debug('Full cart contents: {0}', JSON.stringify(cart));
}
// Check before expensive calculations
if (log.isInfoEnabled()) {
var stats = calculateDetailedStats(); // expensive
log.info('Statistics: {0}', JSON.stringify(stats));
}
// Available checks
log.isDebugEnabled(); // true if debug logging enabled
log.isInfoEnabled(); // true if info logging enabled
log.isWarnEnabled(); // true if warn logging enabled
log.isErrorEnabled(); // true if error logging enabled
Static Level Checks
var Logger = require('dw/system/Logger');
if (Logger.isDebugEnabled()) {
Logger.debug('Debug message');
}
Message Formatting
Messages support Java MessageFormat syntax:
var Logger = require('dw/system/Logger');
var log = Logger.getLogger('order');
// Positional parameters
log.info('Order {0} has {1} items totaling {2}', orderNo, itemCount, total);
// Same paramet
Установить b2c-logging в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл b2c-logging?
Implement server-side logging with dw.system.Logger, custom log categories, and named log files. Use this skill whenever the user needs to add debug or error logging to Commerce scripts, write to a dedicated log file, configure log categories and levels, or use nested diagnostic context for tracing. Also use when setting up logging in controllers, hooks, or job scripts -- even if they just say 'add logging to my script' or 'write to a custom log file'.
Как установить скилл b2c-logging?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл b2c-logging запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic