Skip to main content
Winter Boot uses Monolog as its logging engine and wraps it with the Wlf4p trait so that every class in your application gains a consistent, zero-boilerplate logging API. The trait resolves the correct logger and log level for each class automatically — including any per-class or per-namespace level overrides you define in logger.yml — so you never have to manage logger instances directly.

The Wlf4p Trait

Add use Wlf4p; to any class to access the full suite of logging methods. All methods are static, but because PHP traits inherit static::class, they log under the name of the calling class, not the trait itself.

Available Methods

method
Emits a DEBUG level log record.
method
Emits an INFO level log record.
method
Emits a NOTICE level log record.
method
Emits a WARNING level log record.
method
Emits an ERROR level log record.
method
Emits a CRITICAL level log record.
method
Emits an ALERT level log record.
method
Emits an EMERGENCY level log record.
method
Emits an ERROR record, prepends $message, and appends the full backtrace.
method
Emits an ERROR record with the exception class, code, message, file, and line.

Usage Example

OrderService.php

Configuration — logger.yml

Create a file named logger.yml in the config directory you specify in WinterBootApplication. Winter Boot loads this file at startup and configures Monolog accordingly. The configuration format follows the monolog-cascade schema, which lets you declare loggers, handlers, formatters, and processors entirely in YAML.
config/logger.yml

Key Configuration Sections

Defines one or more named loggers. Each logger references the handlers and processors it uses. The custom_level map lets you control the effective log level for individual classes or entire namespaces without touching your code.
Declares Monolog formatter instances. LineFormatter supports a custom format string using Monolog’s placeholder tokens: %datetime%, %channel%, %level_name%, and %message%.
Declares where log records are written. StreamHandler writes to files or streams such as php://stdout. Each handler references a formatter and optionally its own processors.
Declares Monolog processors that enrich log records. WebProcessor appends HTTP request details; MemoryUsageProcessor appends current memory usage.

Per-Class Log Levels with custom_level

The custom_level map under a logger accepts fully-qualified class names or namespace prefixes as keys. The longest matching prefix wins. This lets you enable verbose debugging for a single service while keeping everything else at a higher threshold. Supported levels: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY, and NONE (suppresses all output).
config/logger.yml
For advanced configuration — such as multiple loggers, log rotation, or remote handlers — refer to the monolog-cascade documentation.