承接 desthercz/logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

desthercz/logger

Composer 安装命令:

composer require desthercz/logger

包简介

Logging package for Laravel 5+

README 文档

README

#Logger

Logger complements or replaces standard Laravel logging. It logs to local files and optionally provides email alerts.

###Installation

Register the service provider:
DestherCZ\Logger\LoggerServiceProvider::class,

Add facade reference:
'Logger' => DestherCZ\Logger\LoggerFacade::class,

Configuration

Publish the configuration file with: php artisan vendor:publish --provider=DestherCZ\Logger\LoggerServiceProvider.

  • 'laravel' => true, captures Laravel log facade messages
  • 'folder' => 'custom' sets the default subfolder for custom logs
  • 'daily' => [] list of log files to be handled as daily logs
  • 'max_daily' => 7 maximum number of daily log files to keep
  • 'email.send' => false turns sending of error emails on/off
  • 'email.level' => 'ERROR' sets the level at which email notifications are sent
  • 'email.recipient' => 'recipient@example.com', sets the email recipient

Usage

Use the facade to write to custom log files. By default files are stored in storage/logs/custom:

Logger::info('auth', 'User login from 1.2.3.4');
Logger::warning('audit', 'A record was updated');
Logger::error('exceptions', 'Fatal exception: ');  

If you wish to store a logfile in a subfolder, use dot notation:

Logger::info('audit.auth', 'User login from 1.2.3.4'); // Logs to `storage/logs/custom/audit/auth.log`

A requestInfo() method is available to provide context for the message, including IP address, request type/URL, Auth::user()->id and input data

Logger::warning('audit', 'An unusual request', Logger::requestInfo());

Fatal errors occurring during the logging process, are stored in storage/logs/fatal-logger-errors.log. For example, a message will be logged here when the system is unable to send an error notification.

Hook into Laravel exceptions:

Make sure the logger.laravel configuration option is set to true, and update your error handler:

// app/Exceptions/Handler.php
use Logger;

public function report(Exception $e)
{
    $class = (new \ReflectionClass($e))->getShortName();
    Logger::error('exceptions', "Exception {$class} | {$e->getMessage()}", Logger::requestInfo());
    return parent::report($e);
}

Email alerts

Emails are only triggered if email sending is turned on, app.debug is false and the relevant error level meets the requirement. The Laravel mail system must be configured for emails to function.

Database handler

  • Add the table using php artisan logger:migration and php artisan migrate
  • Use the config file to set which channels should be logged to the database
  • You may now query the database using the Eloquent model DbEntry

Changelog

  • v0.6: Enable daily log files by configuration
    • Upgrade: add new config file entries: 'daily' => [], 'max_daily' => 7,
  • v0.5: Enable configuration of base folder and dot notation for subfolders
    • Upgrade: add new config file entry: 'folder' => 'custom',
  • v0.4: Add database handler.
    • Upgrade: add new config file entries. To log entries to the database, add and run the migration, then update config file settings accordingly.
  • v0.3: Remove Papertrail handler, use config file instead of .env, require PHP7.
    • Upgrade: publish and update the config file, make sure Papertrail handler is not required.

desthercz/logger 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-01