PHP code example of lombokclarion / log

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

    

lombokclarion / log example snippets


LombokClarion\Log

use LombokClarion\Log\ChannelLogger;
use LombokClarion\Log\Handlers\StreamHandler;
use LombokClarion\Log\LogLevel;

$logger = new ChannelLogger([
    new StreamHandler(
        path: 'storage/logs/app.log',
        minimumLevel: LogLevel::Info,
        daily: true,
        retentionDays: 14,
    ),
], channel: 'app');

$logger->log(LogLevel::Info, 'User logged in', ['user_id' => 42]);

// Convenience methods (via LogsConveniently trait on ChannelLogger):
$logger->info('Order placed', ['order_id' => 99]);
$logger->error('Payment failed', ['reason' => 'timeout']);