PHP code example of goszowski / laravel-database-log-channel

1. Go to this page and download the library: Download goszowski/laravel-database-log-channel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

goszowski / laravel-database-log-channel example snippets


return [
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'database'], // Add "database" channel
            'ignore_exceptions' => false,
        ],

        // ...
        'database' => [
            'driver' => 'monolog',
            'handler' => Goszowski\DatabaseLogChannel\Logging\DatabaseLogHandler::class,
            'via' => Goszowski\DatabaseLogChannel\Logging\DatabaseLogger::class,

            'alternative-log-channel' => 'daily', // Use an alternate channel when it is not possible to write to the database
            'connection' => null, // Use default connection
            'table' => 'logs',
            'async' => true, // If true, will be sent to the queue
            'queue' => 'default', // Define a queue for asynchronous logging
            'level' => 'error',
        ],

    ],
];

use Log;

Log::error('My error message');

$schedule->command('database-logs:prune')->daily();

$schedule->command('database-logs:prune --hours=48')->daily();
bash
php artisan vendor:publish --tag="database-log-channel-migrations"
php artisan migrate