New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

okaufmann/laravel-notification-log

Logs every sent Notification and Mail of your entire Project.
30,628 4
Install
composer require okaufmann/laravel-notification-log
Latest Version:v6.1.0
PHP:^8.3
Laravel:12 · 13
Older releases:9 · 10 · 11
License:MIT
Last Updated:Jun 22, 2026
Links: GitHub  ·  Packagist
Maintainer: okaufmann

Laravel Notification Log

Latest Version on Packagist Tests PHPStan Check & fix styling Total Downloads

Logs every sent Notification of your entire Laravel Project.

Installation

You can install the package via composer:

composer require okaufmann/laravel-notification-log

You can publish and run the migrations with:

php artisan vendor:publish --tag="notification-log-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="notification-log-config"

The following config file will be published in config/notification-log.php:

return [

    /*
    |--------------------------------------------------------------------------
    | Resolve Notification Message
    |--------------------------------------------------------------------------
    |
    | If this is enabled, the Logger will try to resolve the built message
    | out of the notification. This is useful if you want to debug your
    | sent notifications.
    |
    */

    'resolve_notification_message' => env('NOTIFICATION_LOG_RESOLVE_NOTIFICATION_MESSAGE', false),
];

Usage

Add the following Interface and Trait to your Notification:

use Okaufmann\LaravelNotificationLog\Contracts\ShouldLogNotification;use Okaufmann\LaravelNotificationLog\Models\Concerns\LogsNotifications;

class DummyNotification extends Notification implements ShouldLogNotification
{
    use LogsNotifications;

    // ...

}

Now send a Notification or Mail as you would normally do. The package will automatically log the Notification or Mail.

Custom Message Resolution

If you want to customize how the notification message is resolved for logging purposes, you can implement the ResolveMessageForLogging interface:

use Okaufmann\LaravelNotificationLog\Contracts\ShouldLogNotification;
use Okaufmann\LaravelNotificationLog\Contracts\ResolveMessageForLogging;
use Okaufmann\LaravelNotificationLog\Models\Concerns\LogsNotifications;

class CustomNotification extends Notification implements ShouldLogNotification, ResolveMessageForLogging
{
    use LogsNotifications;

    public function resolveMessageForLogging(string $channel, $notifiable): string
    {
        $channelName = get_class($channel);
        $notifiableName = get_class($notifiable);

        return "Custom message for {$channelName} channel sent to {$notifiableName}";
    }
}

When a notification implements ResolveMessageForLogging, the logger will use your custom method instead of the default message resolution logic. This gives you full control over what gets stored in the message field of the notification log.

Resolving Messages After Sending

For special channels like WhatsApp, Telegram, or other messaging services where templates are stored externally and the actual message content is only available after sending, you can implement the ResolveMessageForLoggingAfterSent interface:

use Okaufmann\LaravelNotificationLog\Contracts\ShouldLogNotification;
use Okaufmann\LaravelNotificationLog\Contracts\ResolveMessageForLoggingAfterSent;
use Okaufmann\LaravelNotificationLog\Models\Concerns\LogsNotifications;

class WhatsAppNotification extends Notification implements ShouldLogNotification, ResolveMessageForLoggingAfterSent
{
    use LogsNotifications;

    public function resolveMessageForLoggingAfterSent(mixed $channel, $notifiable, $response): ?string
    {
        // Extract the actual message content from the WhatsApp API response
        if (isset($response['message_id'])) {
            return "WhatsApp message sent with ID: {$response['message_id']}";
        }

        return null;
    }
}

This interface is particularly useful for channels where:

  • Templates are stored externally (like WhatsApp Business API)
  • The actual message content is only available after sending
  • You need to extract information from the channel's response data

The method is called during the NotificationSent event, allowing you to resolve the message content using the response data from the channel after the notification has been successfully sent.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

spatie/laravel-notification-log

Log notifications sent by your Laravel app

1,335,587 212
teamnovu/laravel-notification-log

Logs every sent Notification and Mail of your entire Project.

5,813 2
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443

Version History

Version Released PHP Laravel License
v6.1.0 ^8.3 ^12.0|^13.0 MIT
v6.0.0 ^8.3 ^12.0|^13.0 MIT
5.2.2 ^8.3 ^11.0|^12.0 MIT
5.2.1 ^8.3 ^11.0|^12.0 MIT
5.2.0 ^8.3 ^11.0|^12.0 MIT