Looking to hire Laravel developers? Try LaraJobs

laravel-log maintained by enkidu

Description
Laravel Log
Last update
2020/03/27 02:35 (dev-master)
License
Links
Downloads
2
Tags

Comments
comments powered by Disqus

Laravel Log

Existing Logs

Exception Log

try {
        throw new Exception('Test');
    } catch (Exception $exception) {
        \Enkidu\Log\Facades\ExceptionLogger::logException($exception); // exception.log
    }

Debug Log

\Enkidu\Log\Facades\DebugLogger::info('Test'); // debug.log

Creating custom log

  • Add logging channel in config/logging.php
   'channels' => [
   ...
   'test' => [
        'driver' => 'single',
        'path' => storage_path('logs/test.log'),
        'level' => 'info',
   ],
  ...
]
  • Create custom logging class
class TestLogger extends BaseLogger
{
    /**
     * @inheritDoc
     */
    protected function getLoggingChannel(): string
    {
        return 'test';
    }
}

How to use

$test = new \App\Logger\TestLogger;
 $test->info('Test'); // test.log