New

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

markhilton/monolog-mysql

Laravel 8 MySQL driver for Monolog
166,685 40

Larablocks Analysis

markhilton/monolog-mysql works with any PHP project: the latest release (0.1.6, May 2, 2017) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: marked abandoned on Packagist.

  • Marked abandoned on Packagist
  • No release in the last 12 months (last: May 2, 2017)
  • 3,989 downloads a month (needs 10,000)
  • 40 GitHub stars (needs 100)

State

Abandoned
  • Packagist marks this package abandoned.
  • Last stable release: May 2, 2017.
  • No releases in the last 12 months.
  • First released: Apr 7, 2017.
  • Monthly downloads: 3,989, up 78% from six months ago.
  • 7 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.

Install
composer require markhilton/monolog-mysql
Latest Version:0.1.6
PHP:>=5.5.9
License:MIT
Last Updated:Apr 12, 2021
Links: GitHub  ·  Packagist
Maintainer: jbravo

Laravel Monolog MySQL Handler.

This package will log errors into MySQL database instead storage/log/laravel.log file.

Installation

composer require markhilton/monolog-mysql

Open up config/app.php and find the providers key.

'providers' => array(
    // ...
    Logger\Laravel\Provider\MonologMysqlHandlerServiceProvider::class,
);

Publish config using Laravel Artisan CLI.

php artisan vendor:publish

Migrate tables - you may want to configure enviornment beforehand.

php artisan migrate

Application Integration

In your application config/logging.php add:

use Logger\Monolog\Handler\MysqlHandler;

// ...

'channels' => [
    // ...
    'mysql' => [
        'driver' => 'monolog',
        'handler' => MysqlHandler::class,
        'level' => 'debug',
    ],
];

Application Integration (Laravel >= 5.6)

In your application config/logging.php add:

<?php
    // [...]
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['mysql'],
        ],
        // [...]
        'mysql' => [
            'driver' => 'custom',
            'via' => App\Logging\CreateMySQLLogger::class,
        ],
    ],

In your application app/Logging/CreateMySQLLogger.php add:

<?php
namespace App\Logging;
use Exception;
use Monolog\Logger;
use Logger\Monolog\Handler\MysqlHandler;
class CreateMySQLLogger
{
    /**
     * Create a custom Monolog instance.
     *
     * @param  array $config
     * @return Logger
     * @throws Exception
     */
    public function __invoke(array $config)
    {
        $channel = $config['name'] ?? env('APP_ENV');
        $monolog = new Logger($channel);
        $monolog->pushHandler(new MysqlHandler());
        return $monolog;
    }
}

Environment configuration

If you wish to change default table name to write the log into or database connection use following definitions in your .env file

DB_LOG_TABLE=logs
DB_LOG_CONNECTION=mysql

Credits

Based on:

Alternatives to markhilton/monolog-mysql

danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB d...

1,138,529 133
itelmenko/laravel-mysql-logger

Laravel MySQL driver for Monolog

160,239 21
bureaupartners/laravel-loki-logging

Zero-config Grafana Loki log driver for Laravel. Real-time, fault-tolerant, with...

7,145 0
codeinternetapplications/monolog-stackdriver

Stackdriver handler for Monolog.

188,536 14

Version History

Version Released PHP License
0.1.6 >=5.5.9 MIT
0.1.5 >=5.5.9 MIT
0.1.4 >=5.5.9 MIT
0.1.3 >=5.5.9 MIT
0.1.2 >=5.5.9 MIT