PHPackages                             kaoken/laravel-db-email-log - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. kaoken/laravel-db-email-log

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

kaoken/laravel-db-email-log
===========================

Save logs handled by Laravel in DB, and send mail when it is over specified level.

1.0.0(4y ago)06MITPHPPHP &gt;=7.3.0

Since Jan 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kaoken/laravel-db-email-log)[ Packagist](https://packagist.org/packages/kaoken/laravel-db-email-log)[ Docs](https://github.com/kaoken/laravel-db-email-log)[ RSS](/packages/kaoken-laravel-db-email-log/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

laravel-db-email-log
====================

[](#laravel-db-email-log)

Save logs handled by Laravel in Mysql, and send mail when it is over specified level.

![Travis](https://camo.githubusercontent.com/93e9bdc997124001df0d8bf7f2dc91869204ec9f36382397ecdf5eddb4db9b37/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f727573742d6c616e672f727573742e737667)[![composer version](https://camo.githubusercontent.com/34e695c6016bc2a934a96bed696e29b2f2ab562a7134d65a55d00653cd506bea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c75652e737667)](https://github.com/kaoken/laravel-db-email-log)[![licence](https://camo.githubusercontent.com/84ba0b50ad44e854f0382b3a99afaef96f3d4db9e861686a3297ccd3bd397de7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d626c75652e737667)](https://github.com/kaoken/laravel-db-email-log)[![laravel version](https://camo.githubusercontent.com/857ef96071daf008c4c72368ee0ea11fe65ed75c5f75f3dcdc8a16b6d97b5b56/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c25323076657273696f6e2d254532253839254137382e37372e312d7265642e737667)](https://github.com/kaoken/laravel-db-email-log)

**Table of content**

- [Install](#install)
- [Setting](#setting)
- [Event](#event)
- [License](#license)

Install
-------

[](#install)

**composer**:

```
composer require kaoken/laravel-db-email-log
```

or, add `composer.json`

```
  "require": {
    ...
    "kaoken/laravel-db-email-log":"^1.0"
  }
```

Setting
-------

[](#setting)

### Add to **`config\app.php`** as follows:

[](#add-to-configappphp-as-follows)

```
    'providers' => [
        ...
        // Add
        Kaoken\LaravelDBEmailLog\LaravelDBEmailLogServiceProvider::class
    ],
```

### Add to **`config\database.php`** as follows:

[](#add-to-configdatabasephp-as-follows)

```
    'connections' => [
        ...
        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
        // Add (Copy 'mysql' above)
        'db_log' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
        ...
```

Copy the above `['connections']['mysql']` and set the driver name to `db_log`. This is necessary to prevent the log from being lost due to rollback after writing the log when doing transaction processing (`DB :: transaction`,` DB :: beginTransaction` etc.) with the driver name `mysql`.

### Add to **`config\logging.php`** as follows:

[](#add-to-configloggingphp-as-follows)

- `connection` is the driver name for the data. See `config\database.php`.
- `model` is a log model.
- `email` sends a mail according to` email_send_level` if it is `true`. In case of `false`, do not send anything.
- `email_send_level` specifies the log level and send from the specified log level or higher. Since the priority is low, `DEBUG`、`INFO`、`NOTICE`、`WARNING`、 `ERROR`、`CRITICAL`、`ALERT`、`EMERGENCY`.Capital letters and lower case letters are not distinguished.
- `email_log` should modify the class derived from [Mailable](https://laravel.com/docs/8.x/mail) as necessary. Send log mail.
- `email_send_limit` should modify the class derived from [Mailable](https://laravel.com/docs/8.x/mail) as necessary. Send when e-mail transmission limit `max_email_send_count` is exceeded.
- `max_email_send_count`, the log e-mail that can be transmitted in one day. A simple warning mail is sent when the number exceeds the number of transmissions. See `email_send_level`.
- `to` is the destination of the mail.

It is good to add it under the `'log_level' => env('APP_LOG_LEVEL', 'debug'),` of the `config\app.php` file.

```
    'default' => env('LOG_CHANNEL', 'db_log'),
    // Add
    'db_log' => [
        'connection' => 'db_log',
        'model' => Kaoken\LaravelDBEmailLog\Model\Log::class,
        'email' => true,
        'email_send_level' => 'ERROR',
        'email_log' => Kaoken\LaravelDBEmailLog\Mail\LogMailToAdmin::class,
        'email_send_limit' => Kaoken\LaravelDBEmailLog\Mail\SendLimitMailToAdmin::class,
        'max_email_send_count' => 64,
        'to' => 'hoge@hoge.com'
    ],
```

### Command

[](#command)

```
php artisan vendor:publish --tag=db-email-log
```

After execution, the following directories and files are added.

- **`database`**
    - **`migrations`**
        - `2021_01_01_000001_create_logs_table.php`
- **`resources`**
    - **`views`**
        - **`vendor`**
            - **`mysql_email_log`**
                - `log.blade.php`
                - `over_limit.blade.php`

### Migration

[](#migration)

Migration file `2021_01_01_000001_create_logs_table.php` should be modified as necessary.

```
php artisan migrate
```

### E-Mail

[](#e-mail)

In the configuration `config\logging.php` of the above setting, The `Kaoken\LaravelDBEmailLog\Mail\ConfirmationMailToUser::class` of `email_log` is used as the log mail of the target level or higher. The template uses `views\vendor\mysql_email_log\log.blade.php`. Change according to the specifications of the application.

The `Kaoken\LaravelDBEmailLog\Mail\ConfirmationMailToUser::class` of `email_send_limit` is used when the log above the target level reaches the send limit. The template uses `views\vendor\mysql_email_log\over_limit.blade.php`. Change according to the specifications of the application.

Event
-----

[](#event)

See inside the `vendor\laravel-db-email-log\src\Events` directory!

#### `BeforeWriteLogEvent`

[](#beforewritelogevent)

Called before writing the log.

License
-------

[](#license)

[MIT](https://github.com/kaoken/laravel-confirmation-email/blob/master/LICENSE.txt)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1642d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6100263?v=4)[kaoken(kenji yasuda)](/maintainers/kaoken)[@kaoken](https://github.com/kaoken)

---

Top Contributors

[![kaoken](https://avatars.githubusercontent.com/u/6100263?v=4)](https://github.com/kaoken "kaoken (1 commits)")

---

Tags

laravelemailmonolog

### Embed Badge

![Health badge](/badges/kaoken-laravel-db-email-log/health.svg)

```
[![Health](https://phpackages.com/badges/kaoken-laravel-db-email-log/health.svg)](https://phpackages.com/packages/kaoken-laravel-db-email-log)
```

###  Alternatives

[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14845.8k1](/packages/guanguans-laravel-exception-notify)[open-telemetry/opentelemetry-auto-laravel

OpenTelemetry auto-instrumentation for Laravel

592.7M9](/packages/open-telemetry-opentelemetry-auto-laravel)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[nightowl/agent

NightOwl monitoring agent — collects telemetry from laravel/nightwatch and writes to PostgreSQL

771.7k](/packages/nightowl-agent)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[binarybuilds/laravel-mail-manager

A Laravel mail manager to record and re-send all outgoing emails.

2440.3k1](/packages/binarybuilds-laravel-mail-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
