portavice/laravel-log-errors-to-mail
最新稳定版本:v1.2.0
Composer 安装命令:
composer require portavice/laravel-log-errors-to-mail
包简介
Adds a logging channel that sends log messages via email to a configured email address
README 文档
README
This package adds a basic logging channel that sends E-Mails for messages from a specific error level upwards to preconfigured recipients using a Laravel mail transport.
Prerequisites
- A configured default Laravel mail driver
Installation
composer require portavice/laravel-log-errors-to-mail
Configuration
To configure your Laravel application to use the logger, you should create a logging channel in your logging.php
configuration file.
For example a stack channel that logs to the default stack and sends email notifications:
return [ // ... 'channels' => [ // ... 'stack_with_email' => [ 'driver' => 'stack', 'channels' => ['stack', 'log_errors_to_mail'], 'ignore_exceptions' => false, ], ], // ... ];
You may then set the logging channel in your .env file or as the default logging channel in your logging.php.
LOG_CHANNEL=stack_with_email
Customization
The library offers some customization for the default laravel_mail_logger channel via environment variables.
# defaults # the name of the laravel mailer to use when sending email. (blank by default) # if omitted, uses the global default mailer configured for your laravel application LOG_ERROR_TO_MAIL_MAILER= # recipient of the error emails (blank by default) LOG_ERROR_TO_MAIL_TO= # deduplicate error emails (on by default) LOG_ERROR_TO_MAIL_DEDUPLICATE=true # minimum PSR log level to send emails for (error by default) LOG_ERROR_TO_MAIL_LEVEL=error
It's also possible to publish the configuration for this package with the artisan vendor:publish command.
$ php artisan vendor:publish --tag=laravel-log-errors-to-mail
Choosing the Mail Transport
By default, the application uses the default mail driver of your Laravel application.
To change the driver used, you may publish the logger configuration and change the "laravel_log_errors_to_mail.email_driver" option to the mail driver name you desire.
The mail driver should extend the \Illuminate\Mail\Mailer class and return
a valid \Symfony\Component\Mailer\Transport\TransportInterface instance from the Mailer::getSymfonyTransport()
Method.
Known issues
Mail drivers using a 'log' transport
Mail drivers using a \Illuminate\Mail\Transport\LogTransport transport are not supported and the EmailHandler will
fall back to a NoopHandler.
However, this automatic fallback currently only works if the selected driver directly uses a LogTransport.
If you for example set a RoundRobinTransport with a LogTransport mail driver, it will end up in
an infinite recursion loop.
portavice/laravel-log-errors-to-mail 适用场景与选型建议
portavice/laravel-log-errors-to-mail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.27k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「logging」 「mail」 「laravel」 「e-mail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 portavice/laravel-log-errors-to-mail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 portavice/laravel-log-errors-to-mail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 portavice/laravel-log-errors-to-mail 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
统计信息
- 总下载量: 2.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-29