crasivo / bitrix-monolog
Monolog library adapter for 1C-Bitrix
Fund package maintenance!
crasivo
Requires
- php: ^8.1
- monolog/monolog: ^3.0
This package is auto-updated.
Last update: 2025-09-12 01:08:51 UTC
README
Adapter for the popular Monolog library in 1C-Bitrix & Bitrix24.
Implementation features:
- Simple and quick integration into an existing project
- Flexible configuration (like laravel/symfony)
- Isolation of kernel settings and specific module settings
- Backward compatibility with standard loggers
- Handling critical errors through the exception_handling configuration.
- Quick integration with external services (Graylog, Logstash, Sentry etc).
Minimum requirements for installation:
- 1C-Bitrix kernel version (main):
v20.5.400
- PHP version:
v7.2
- Monolog version:
v2.10
🚀 Quick Start
To use the library, simply install the Composer package via the command:
$ cd /path/to/project
$ composer require crasivo/bitrix-monolog
It is initially assumed that autoload.php
is already connected to your project.
If this is not the case, it can be added to one of the following files:
/bitrix/.settings.php
/bitrix/.settings_extra.php
/local/php_interface/init.php
The service is already pre-configured (default logger).
This is quite enough to start logging messages anywhere in your project.
Access to the logger and other objects is through a separate ServiceLocator
class (service locator).
Example of accessing the logger through the service locator:
use Crasivo\Bitrix\Monolog\ServiceLocator as MonologLocator; $locator = MonologLocator::getInstance(); $logger = $locator->getLogger('default'); $logger->info('Hello world!');
You can also use the ready-made helper function (alternative):
logger()->info('Hello world!');
Warning
Direct call of any method in files such as .settings.php
can lead to looping (stack overflow).
Keep this in mind during development!
To configure logging of critical errors, it is sufficient to declare the corresponding class.
return [ 'exception_handling' => [ 'value' => [ 'debug' => false, 'handled_errors_types' => E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE, 'exception_errors_types' => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_USER_WARNING & ~E_USER_NOTICE & ~E_COMPILE_WARNING & ~E_DEPRECATED, 'ignore_silence' => false, 'assertion_throws_exception' => true, 'assertion_error_type' => E_USER_ERROR, 'log' => [ 'class_name' => Crasivo\Bitrix\Monolog\ExceptionHandlerLog::class, 'settings' => [ 'logger' => 'default', ], ], ], 'readonly' => true, ], ];
In the examples
folder, you can see examples with settings and using the library.
Note
More detailed documentation with usage examples will be written and published later. Estimated release date — Q4 2025.
📜 License
This project is distributed under the MIT license. The full text of the license can be read in the LICENSE file.