bitrix-logger
Installation
SKILL.md
Logging in Bitrix (PSR-3)
Bitrix follows the PSR-3 standard. In code, inject \Psr\Log\LoggerInterface, and in .settings.php, configure the specific implementation. Direct calls to AddMessage2Log are legacy; in new code, write via DI logger.
Built-in Implementations
All are in the \Bitrix\Main\Diag\ namespace:
| Class | Purpose |
|---|---|
Logger |
Abstract base class; Logger::create('id', $params) creates a logger via factory |
FileLogger |
Into a file, with auto-rotation when $maxLogSize is exceeded (default 1 MB) |
SysLogger |
Into system syslog via openlog/syslog |
EventLogger |
Into b_event_log table (Admin Panel → Event Log) |
LogFormatter |
Default formatter: interpolates {placeholder}, renders exceptions and stacks |
JsonLinesFormatter |
From 25.300.0; one JSON line per entry, convenient for ELK/Loki |
Levels are constants of \Psr\Log\LogLevel::* (emergency, alert, critical, error, warning, notice, info, debug).