PHPackages                             kaoken/laravel-mysql-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. [Database &amp; ORM](/categories/database)
4. /
5. kaoken/laravel-mysql-email-log

ActiveLibrary[Database &amp; ORM](/categories/database)

kaoken/laravel-mysql-email-log
==============================

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

1.8.5(6y ago)1301MITPHPPHP &gt;=7.1.3

Since Jan 9Pushed 6y ago1 watchersCompare

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

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

laravel-mysql-email-log
=======================

[](#laravel-mysql-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/c764ed49635b36816a62919d5cf1f682f39bf52dd375399d036451062a7e1a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e382e352d626c75652e737667)](https://github.com/kaoken/laravel-mysql-email-log)[![licence](https://camo.githubusercontent.com/84ba0b50ad44e854f0382b3a99afaef96f3d4db9e861686a3297ccd3bd397de7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d626c75652e737667)](https://github.com/kaoken/laravel-mysql-email-log)[![laravel version](https://camo.githubusercontent.com/f50a3e061818b18ff3aac4a571e980f7ad3a685837bad6c97788838ec8edd4f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c25323076657273696f6e2d254532253839254137352e382d7265642e737667)](https://github.com/kaoken/laravel-mysql-email-log)

**Table of content**

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

Install
-------

[](#install)

**composer**:

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

or, add `composer.json`

```
  "require": {
    ...
    "kaoken/laravel-mysql-email-log":"^1.8.5"
  }
```

Setting
-------

[](#setting)

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

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

```
    'providers' => [
        ...
        // Add
        Kaoken\LaravelMysqlEmailLog\LaravelMysqlEmailLogServiceProvider::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)
        'mysql_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 `mysql_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)

- `driver` is a `monolog`.
- `handler` is a `Kaoken\LaravelMysqlEmailLog\LaravelMysqlEmailLogHandler::class`.
- `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/5.5/mail) as necessary. Send log mail.
- `email_send_limit` should modify the class derived from [Mailable](https://laravel.com/docs/5.5/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.

```
    // Add
    'mysql_log' => [
        'driver' => 'monolog',
        'handler' => Kaoken\LaravelMysqlEmailLog\LaravelMysqlEmailLogHandler::class,
        'model' => Kaoken\LaravelMysqlEmailLog\Model\Log::class,
        'email' => true,
        'email_send_level' => 'ERROR',
        'email_log' => Kaoken\LaravelMysqlEmailLog\Mail\LogMailToAdmin::class,
        'email_send_limit' => Kaoken\LaravelMysqlEmailLog\Mail\SendLimitMailToAdmin::class,
        'max_email_send_count' => 64,
        'to' => 'hoge@hoge.com'
    ],
```

#### Modify `.env` to enable logging

[](#modify-env-to-enable-logging)

Make corrections as follows

```
LOG_CHANNEL=mysql_log
```

### Command

[](#command)

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

After execution, the following directories and files are added.

- **`database`**
    - **`migrations`**
        - `2017_09_17_000001_create_logs_table.php`
- **`resources`**
    - **`views`**
        - **`vendor`**
            - **`mysql_email_log`**
                - `log.blade.php`
                - `over_limit.blade.php`

### Migration

[](#migration)

Migration file `2017_09_17_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\LaravelMysqlEmailLog\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\LaravelMysqlEmailLog\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-mysql-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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Every ~514 days

Total

2

Last Release

2530d ago

PHP version history (2 changes)1.0.5PHP &gt;=7.0.0

1.8.5PHP &gt;=7.1.3

### Community

Maintainers

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

---

Tags

laravelemailmysqlmonolog

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[itelmenko/laravel-mysql-logger

Laravel MySQL driver for Monolog

21141.9k](/packages/itelmenko-laravel-mysql-logger)[markhilton/monolog-mysql

Laravel 8 MySQL driver for Monolog

40140.8k](/packages/markhilton-monolog-mysql)[addapp/laravel-query-log

Logs full mysql queries.

135.4k](/packages/addapp-laravel-query-log)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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