PHP code example of yoeriboven / laravel-log-db

1. Go to this page and download the library: Download yoeriboven/laravel-log-db 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/ */

    

yoeriboven / laravel-log-db example snippets


use Illuminate\Support\Facades\Log;

Log::channel('db')->info('Your message');

use Yoeriboven\LaravelLogDb\DatabaseLogger;

return [
    'channels' => [
        'db' => [
            'driver'     => 'custom',
            'via'        => DatabaseLogger::class,
            'connection' => env('LOG_DB_CONNECTION'), // Optional, defaults to app's DB connection
            'days'       => 7, // Optional, retention period in days
        ],
    ]   
]

// config/logging.php
return [
    'channels' => [
        'stack' => [
            'channels' => ['single', 'db'],
        ],
        // other channels
    ]
]

use Illuminate\Support\Facades\Log;

Log::channel('db')->info('Your log message');

// config/logging.php

return [
    'channels' => [
        'fallback' => [
            'channels' => ['single'],
        ],
    ]   
]

$schedule->command('model:prune', [
    '--model' => [
        \Yoeriboven\LaravelLogDb\Models\LogMessage::class,
    ],
])->daily();
bash
php artisan vendor:publish --tag="log-db-migrations"
php artisan migrate