PHP code example of ahmedash95 / logwriter

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

    

ahmedash95 / logwriter example snippets


// config/app.php
'providers' => [
    ...
    Ahmedash95\LogWriter\Providers\LogWriterServiceProvider::class,

];

// Register alias
'aliases' => [
    ...
    'LogWriter' => Ahmedash95\LogWriter\Facades\LogWriterFacade::class,
    
];



use Monolog\Logger;

return [

    /*
     * The base path of log files
     */
    'log_path' => storage_path(),

    /*
     * The Log channels.
     */
    'channels' => [
        'event' => [
            'path'  => 'logs/event.log',
            'level' => Logger::INFO,
        ],
        'audit' => [
            'path'  => 'logs/audit.log',
            'level' => Logger::INFO,
        ],
    ],

    /*
     * The Log levels.
     */
    'levels' => [
        'debug'     => Logger::DEBUG,
        'info'      => Logger::INFO,
        'notice'    => Logger::NOTICE,
        'warning'   => Logger::WARNING,
        'error'     => Logger::ERROR,
        'critical'  => Logger::CRITICAL,
        'alert'     => Logger::ALERT,
        'emergency' => Logger::EMERGENCY,
    ],

];

LogWriter::write('event','This is log line into event file');

LogWriter::alert('event','Using log levels');
// or
LogWriter::warning('event','Using log levels');

php artisan vendor:publish --provider="Ahmedash95\LogWriter\Providers\LogWriterServiceProvider"
config/logwriter.php