Error on overriding ConfigureLogging bootstrap class

Posted 4 years ago by aspiresuvedi

While trying to implement logentries on L5, I tried to override ConfigureLogging class. Firstly , I override the $bootstrappers property of HttpKernel in Kernel class. using

protected $bootstrappers = [
        'App\Bootstrap\ConfigureLogging',
        'Illuminate\Foundation\Bootstrap\DetectEnvironment',
        'Illuminate\Foundation\Bootstrap\LoadConfiguration',
        'Illuminate\Foundation\Bootstrap\HandleExceptions',
        'Illuminate\Foundation\Bootstrap\RegisterFacades',
        'Illuminate\Foundation\Bootstrap\RegisterProviders',
        'Illuminate\Foundation\Bootstrap\BootProviders',
    ];

My App\Bootstrap\ConfigureLogging class to implement logentries looks like

<?php namespace App\Bootstrap;

use Illuminate\Log\Writer;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as BaseConfigureLogging;
use Monolog\Handler\LogEntriesHandler;

class ConfigureLogging extends BaseConfigureLogging {

    /**
     * Custom Monolog handler that for Logentries.
     *
     * @param  \Illuminate\Contracts\Foundation\Application  $app
     * @param  \Illuminate\Log\Writer  $log
     * @return void
     */
    protected function configureCustomHandler(Application $app, Writer $log)
    {
        $logentriesHandler = new LogEntriesHandler(getenv('LOGENTRIES_TOKEN'));
        $log->getMonolog()->pushHandler($logentriesHandler);
        // Also Log to Dayily files too.
        $log->useDailyFiles($app->storagePath().'/logs/laravel.log', 5);
    }

}

But it throws error like this

Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist' in /var/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.