Customizing the logging process | laravel-notification-log | Spatie

 SPATIE

  Laravel Notification Log
===========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-notification-log](https://spatie.be/docs/laravel-notification-log/v1)  Advanced-usage  Customizing the logging process

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/laravel-notification-log/v1)

- [ Introduction ](https://spatie.be/docs/laravel-notification-log/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-notification-log/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-notification-log/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-notification-log/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-notification-log/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-notification-log/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-notification-log/v1/about-us)

Basic usage
-----------

- [ Getting started ](https://spatie.be/docs/laravel-notification-log/v1/basic-usage/getting-started)
- [ Determining which notifications get logged ](https://spatie.be/docs/laravel-notification-log/v1/basic-usage/determining-which-notifications-get-logged)
- [ Adding extra info to a logged notifications ](https://spatie.be/docs/laravel-notification-log/v1/basic-usage/adding-extra-info-to-your-notification)
- [ Querying the notification log ](https://spatie.be/docs/laravel-notification-log/v1/basic-usage/querying-the-notification-log)
- [ Working with fingerprints ](https://spatie.be/docs/laravel-notification-log/v1/basic-usage/working-with-fingerprints)

Advanced usage
--------------

- [ Customizing notification types ](https://spatie.be/docs/laravel-notification-log/v1/advanced-usage/customizing-notification-types)
- [ Customizing the logging process ](https://spatie.be/docs/laravel-notification-log/v1/advanced-usage/customizing-the-logging-process)
- [ Handling on demand notifications ](https://spatie.be/docs/laravel-notification-log/v1/advanced-usage/handling-on-demand-notifications)
- [ Using your own notification log model ](https://spatie.be/docs/laravel-notification-log/v1/advanced-usage/using-your-own-notification-log-model)

 Customizing the logging process
===============================

The `ConvertNotificationSendingEventToLogItemAction` class determines how notifications will get logged by default. It contains many methods that can be overridden to customize how notifications will get logged.

To override methods, start by creating a class of your own that extends the default `ConvertNotificationSendingEventToLogItemAction` action. Override any method you want from the base class.

In the following example, we'll create a custom action that will use the base name of a class instead of the fqcn to use as the type.

```
use Spatie\NotificationLog\Actions\ConvertNotificationSendingEventToLogItemAction;

class CustomConversionAction extends ConvertNotificationSendingEventToLogItemAction
{
    protected function getNotificationType(NotificationSending $event): string
    {
        $notification = $event->notification;

        return class_basename($notification);
    }
}
```

You should register your custom class in the `actions.convertEventToModel` key of the `notification-log` config file.

```
return [
    // ...

    'actions' => [
        'convertEventToModel' => CustomConversionAction::class,
    ],
]
```
