Looking to hire Laravel developers? Try LaraJobs

laravel-mail-logging maintained by peroxovy

Description
Package which allows to send logs to e-mail.
Author
Last update
2025/01/31 15:29 (dev-main)
License
Links
Downloads
7

Comments
comments powered by Disqus

This package provides possibility to send an exception to desired e-mail addresses, notifying the administrator about any problems.


Installation:

composer require peroxovy/laravel-mail-logging


Publish config:

php artisan vendor:publish --provider="Peroxovy\LaravelMailLogging\Providers\MailLoggingServiceProvider"

Add the following lines to your .env:

MAIL_LOG_FROM={email address from}
MAIL_LOG_TO={email addresses divided by "," }
MAIL_LOG_SUBJECT={email subject}
MAIL_LOG_MEMORY_USAGE=true/false
MAIL_LOG_MEMORY_PEAK=true/false
MAIL_LOG_WEB=true/false
MAIL_LOG_GIT=true/false

Modify channels section inside your config/logging.php by adding the driver:

'mail' => [
    'driver'    => 'custom',
    'via' => \Peroxovy\LaravelMailLogging\MailLogger::class,
    'from' => env('MAIL_LOG_FROM', 'no-reply@example.com'),
    'to' => explode(',', env('MAIL_LOG_TO', 'admin@example.com')),
    'level' => env('MAIL_LOG_LEVEL', 'error'),
    'subject' => env('MAIL_LOG_SUBJECT', 'This is a subject of a Log'),
    'processors' => [
        'memory_usage' => env('MAIL_LOG_MEMORY_USAGE', true),
        'memory_peak' => env('MAIL_LOG_MEMORY_PEAK', true),
        'web' => env('MAIL_LOG_WEB', true),
        'git' => env('MAIL_LOG_GIT', true),
    ],
],  

Activate the package by modifying your default log channel:

'stack' => [
        'driver' => 'stack',
        'channels' => ['daily', 'mail'],
        'ignore_exceptions' => false,
    ],