crasivo/bitrix-monolog 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

crasivo/bitrix-monolog

最新稳定版本:1.0.0

Composer 安装命令:

composer require crasivo/bitrix-monolog

包简介

Monolog library adapter for 1C-Bitrix

README 文档

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.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-10