portavice/laravel-log-errors-to-mail 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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

MIT Licensed

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.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固