credy / yii2-graylog-target

Yii2 graylog2 日志目标

1.0.0 2023-10-31 13:15 UTC

This package is auto-updated.

Last update: 2024-08-30 01:38:37 UTC


README

Build Status codecov PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2 PHP 7.3

Yii2 graylog2 日志目标

安装

安装此扩展的首选方式是通过 Composer

运行以下命令之一

$ composer require credy/yii2-graylog-target

或者在您的 composer.json 文件的 require 部分添加

"credy/yii2-graylog-target": "^0.1"

配置

'as newIdBehavior' => credy\graylog\behaviors\GenerateNewIdBehavior::class,
'components' => [
    'log' => [
        'targets' => [
            [
                'class' => credy\graylog\Target::class,
                'publisher' => [
                    'class' => credy\graylog\Publisher::class,
                    'categories' => ['application'],
                    'facility' => 'my-application',
                    'transports' => [
                        [
                            'class' => credy\graylog\transport\UdpTransport::class,
                            'host' => '192.168.1.1',
                            'port' => 1234,
                            'chunkSize' => 4321,
                        ],
                        [
                            'class' => credy\graylog\transport\TcpTransport::class,
                            'host' => '192.168.1.2',
                            'port' => 1234,
                            'sslOptions' => [
                                'allowSelfSigned' => true,
                                'verifyPeer' => false,
                            ],
                        ]
                    ],
                ],
            ],
        ],
    ],
],

传输方式

UDP 传输

$transport = new credy\graylog\transport\UdpTransport([
    // Host name or IP. Default to 127.0.0.1
    'host' => 'graylog.example.org',
    // UDP port. Default to 12201
    'port' => 1234,
    // UDP chunk size. Default to 8154
    'chunkSize' => 4321,
]);

TCP 传输

$transport = new credy\graylog\transport\UdpTransport([
    // Host name or IP. Default to 127.0.0.1
    'host' => 'graylog.example.org',
    // TCP port. Default to 12201
    'port' => 12201,
    // SSL options. (optional)
    'sslOptions' => [
        // Default to true
        'verifyPeer' => false,
        // Default to false
        'allowSelfSigned' => true,
        // Default to null
        'caFile' => '/path/to/ca.file',
        // Default to null
        'ciphers' => 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256',
    ],
]);

HTTP 传输

$transport = new credy\graylog\transport\HttpTransport([
    // Host name or IP. Default to 127.0.0.1
    'host' => 'graylog.example.org',
    // HTTP port. Default to 12202
    'port' => 12202,
    // Query path. Default to /gelf
    'path' => '/my/custom/greylog',
    // SSL options. (optional)
    'sslOptions' => [
        // Default to true
        'verifyPeer' => false,
        // Default to false
        'allowSelfSigned' => true,
        // Default to null
        'caFile' => '/path/to/ca.file',
        // Default to null
        'ciphers' => 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256',
    ],
]);