定制 aviationcode/laravel-ecs-logging 二次开发

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

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

aviationcode/laravel-ecs-logging

Composer 安装命令:

composer require aviationcode/laravel-ecs-logging

包简介

Logging Laravel log's into Elasticsearch ECS format.

README 文档

README

Latest Version on Packagist Build Status Total Downloads

This package adds ECS (Elastic Common Scheme) format to your laravel application allowing to log your standard logs to elastic.

Installation

You can install the package via composer:

composer require aviationcode/laravel-ecs-logging

It's recommended to require jenssegers/agent which will add user agent logging support.

composer require jenssegers/agent

Optionally, you can publish the config file with:

php artisan vendor:publish --provider="AviationCode\EcsLogging\EcsLoggingServiceProvider" --tag="config"

Register log driver in config/logging.php

return [
    'channels' => [
        // ... Other channels

        'ecs' => [
            'driver' => 'ecs',
            'path' => storage_path('logs/ecs/laravel.json'),
            'level' => 'debug',
            'days' => 14,
        ],
    ]
];

If you want to use this driver as the only logging method define LOG_CHANNEL=ecs in your .env or add the ecs channel into your stack driver.

All Log::xxx() calls get logged into json file. This file can be picked up by filebeat which sends it to your logstash or elasticsearch instance.

Configure filebeat

Add the following to your /etc/filebeat/filebeat.yml file

filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - /path-to-your-laravel-app/storage/logs/ecs/*.json
    json:
      message_key: message
      keys_under_root: true
      overwrite_keys: true

Usage

Event

Event defines something that happened, this could be a single point in time or lasting a certain period. In order to log an event you can add this log context.

Log::info('Password changed for John Doe<john.doe@example.com>', [
    'event' => [
        'action' => 'user-password-change',
        'code' => 4648,
        'outcome' => \AviationCode\EcsLogging\Types\Event::OUTCOME_SUCCESS,
        'type' => 'user',
    ],
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ken.andries.1992@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固