定制 muhammadnurmatov/amqp-gelf-logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

muhammadnurmatov/amqp-gelf-logger

Composer 安装命令:

composer require muhammadnurmatov/amqp-gelf-logger

包简介

README 文档

README

Laravel AMQP GELF Logger — Send Logs to Graylog via AMQP or GELF

Latest Stable Version Total Downloads License

A flexible logger for Laravel 9+, sending logs via AMQP or GELF directly to Graylog for real-time centralized logging and monitoring.

🚀 Installation

Install the package via Composer:

composer require muhammadnurmatov/amqp-gelf-logger

Configuration

1. Config File

You can manually create the config file at config/amqp-gelf-logger.php:

2. Edit config/amqp-gelf-logger.php

return [
     'transport' => env('AMQP_GELF_TRANSPORT', 'tcp'),

    'level' => env('RABBITMQ_LOG_LEVEL', 'debug'),
    'path' => storage_path('logs/amqp-gelf-logger/logs.log'),
    'days' => 14,

    'rabbitmq' => [
        'host' => env('LOG_RABBITMQ_HOST'),
        'port' => env('LOG_RABBITMQ_PORT'),
        'user' => env('LOG_RABBITMQ_USER'),
        'password' => env('LOG_RABBITMQ_PASSWORD'),
        'vhost' => env('LOG_RABBITMQ_VHOST', '/'),
        'exchange' => env('LOG_RABBITMQ_EXCHANGE'),
        'exchange_type' => env('RABBITMQ_EXCHANGE', 'topic'),
        'routing_key' => env('LOG_RABBITMQ_EXCHANGE'),
        'use_tls' => env('LOG_RABBITMQ_USE_TLS', false),
        'verify_peer' => env('LOG_RABBITMQ_VERIFY_PEER', false),
        'verify_peer_name' => env('LOG_RABBITMQ_VERIFY_PEER_NAME', false),
        'cafile' => env('LOG_RABBITMQ_CAFILE', ''),
        'local_cert' => env('LOG_RABBITMQ_LOCAL_CERT', ''),
        'local_pk' => env('LOG_RABBITMQ_LOCAL_PK', ''),
    ],

    'udp' => [
        'host' => env('LOG_UDP_HOST', '127.0.0.1'),
        'port' => env('LOG_UDP_PORT', 555),
        'max_buffer' => env('LOG_UDP_MAX_BUFFER', 1024*20), //20kb
    ],

    'tcp' => [
        'host' => env('LOG_TCP_HOST', '127.0.0.1'),
        'port' => env('LOG_TCP_PORT', 555),
    ]
];

transport - the driver to use for sending messages

If you don't want to use SSL, set use_tls = false in the config.

Logging Channel Setup

Add a custom logging channel in config/logging.php:

'amqp' => [
    'driver' => 'custom',
    'via' => \MuhammadN\AmqpGelfLogger\AmqpGelfLogger::class,
    'name' => 'graylog',
    'level' => 'debug',
    'path' => storage_path('logs/graylog.log'),
    'days' => 14,
],

Usage

You can use the custom logger like any other Laravel log channel:

use Illuminate\Support\Facades\Log;

Log::channel('amqp')->info('User logged in', ['user_id' => 1]);
Log::channel('amqp')->error('Something broke!', ['exception' => $exception]);

Expected Log Structure

{
    "timestamp": "2025-04-07 15:09:12",
    "env_mode": "production",
    "level": "info",
    "channel": "amqp",
    "source": "Test",
    "short_message": "User logged in",
    "context": {
        "user_id": 1
    },
    "server_ip": "127.0.0.1"
}

➕ Optional

If you want to send your default log levels (e.g., error, info, debug) via this handler, you should install this package:

composer require anboz/custom-logger

License

This package is open-sourced software licensed under the MIT license.

muhammadnurmatov/amqp-gelf-logger 适用场景与选型建议

muhammadnurmatov/amqp-gelf-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 294 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 muhammadnurmatov/amqp-gelf-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 muhammadnurmatov/amqp-gelf-logger 我们能提供哪些服务?
定制开发 / 二次开发

基于 muhammadnurmatov/amqp-gelf-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-06