PHP code example of xsga / log4php

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

    

xsga / log4php example snippets


use Xsga\Log4Php\Logger;

// Load configuration from an XML file.
Logger::configure('path/to/log4php.xml');

// Obtain a named logger.
$logger = Logger::getLogger('MyApp');
$logger->info('Application started.');
$logger->warning('Disk space running low.', ['threshold' => '90%']);

// Or use the root logger.
$root = Logger::getRootLogger();
$root->debug('Root logger is ready.');

use Xsga\Log4Php\Logger;

Logger::configure([
    'appenders' => [
        'default' => [
            'class' => 'LoggerAppenderFile',
            'params' => [
                'file' => 'logs/app.log',
            ],
            'layout' => [
                'class' => 'LoggerLayoutPattern',
            ],
        ],
    ],
    'rootLogger' => [
        'level' => 'debug',
        'appenders' => ['default'],
    ],
]);