bri4n0/sql-query-log

Output Laravel SQL query log.

1.0.3 2024-06-01 11:13 UTC

This package is auto-updated.

Last update: 2025-05-29 01:49:00 UTC


README

Install

To install via Composer, run:

composer require bri4n0/sql-query-log

For version <= 11: Add to section providers of config/app.php:

// config/app.php
'providers' => [
    ...
    Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];

For version >= 11: Add to section providers of bootstrap/providers.php:

// bootstrap/providers.php
return [
    ...
    Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];

Set enable SQL query log, Add to .env:

ENABLE_SQL_LOG=true

Others

Custom logging channel:

  1. open file config/logging.php
  2. add channel to section channels:
    'channels' => [
    ...,
     'sql-query-log' => [
            'driver'               => 'daily',
            'path'                 => storage_path('logs/queries.log'),
            'days'                 => env('LOG_DAILY_DAYS', 14),
            'replace_placeholders' => true,
        ],
    ]
  1. enable using sql query log channel:
SQL_LOG_CHANNEL=sql-query-log

Custom logging channel level:

SQL_LOG_LEVEL=debug

License

MIT © Bri4n0