shaffe/laravel-mail-log-channel
最新稳定版本:v2.5.0
Composer 安装命令:
composer require shaffe/laravel-mail-log-channel
包简介
A package to support logging via email in Laravel
关键字:
README 文档
README
A service provider to add support for logging via email using Laravels built-in mail provider.
This package is a fork of laravel-log-mailer by Steve Porter.
Table of contents
Installation
You can install this package via composer using this commande:
composer require shaffe/laravel-mail-log-channel
Laravel version compatibility
| Laravel | Package |
|---|---|
| 6, 7, 8, 9, 10, 11, 12 | ^2.0 |
| 5.6.x | ^1.0 |
The package will automatically register itself if you use Laravel.
For usage with Lumen, add the service provider in bootstrap/app.php.
$app->register(Shaffe\MailLogChannel\MailLogChannelServiceProvider::class);
Configuration
To ensure all unhandled exceptions are mailed:
- create a
maillogging channel inconfig/logging.php, - add this
mailchannel to your current logging stack, - add a
LOG_MAIL_ADDRESSto your.envfile to define the recipient.
You can specify multiple channels and individually change the recipients, the subject and the email template.
'channels' => [ 'stack' => [ 'driver' => 'stack', // 2. Add mail to the stack: 'channels' => ['single', 'mail'], ], // ... // 1. Create a mail logging channel: 'mail' => [ 'driver' => 'mail', 'level' => env('LOG_MAIL_LEVEL', 'notice'), // Specify mail recipient 'to' => [ [ 'address' => env('LOG_MAIL_ADDRESS'), 'name' => 'Error', ], ], 'from' => [ // Defaults to config('mail.from.address') 'address' => env('LOG_MAIL_ADDRESS'), // Defaults to config('mail.from.name') 'name' => 'Errors' ], // Optionally overwrite the subject format pattern // 'subject_format' => env('LOG_MAIL_SUBJECT_FORMAT', '[%datetime%] %level_name%: %message%'), // Optionally overwrite the mailable template // Two variables are sent to the view: `string $content` and `array $records` // 'mailable' => NewLogMailable::class ], ],
Recipients configuration format
The following to config formats are supported:
-
single email address:
'to' => env('LOG_MAIL_ADDRESS', ''),
-
array of email addresses:
'to' => explode(',', env('LOG_MAIL_ADDRESS', '')),
-
associative array of email => name addresses:
'to' => [env('LOG_MAIL_ADDRESS', '') => 'Error'],`
-
array of email and name:
'to' => [ [ 'address' => env('LOG_MAIL_ADDRESS', ''), 'name' => 'Error', ], ],
统计信息
- 总下载量: 78.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-29
