mercredi 14 octobre 2015

Laravel 5.1 Monolog to output in Chrome console

I'm trying to implement monolog so it outputs to chrome console. So far I have this, but when I log a message it doesn't output anything.

Is there anything else that needs to be done to make this work that I've missed?

AppServiceProvider.php

<?php

namespace TNC\Providers;

use Log;
use Monolog\Handler\ChromePHPHandler;
use Monolog\Formatter\ChromePHPFormatter;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Log::listen(function () {

            $monolog = Log::getMonolog();

            if (env('APP_ENV') === 'local') {
                $monolog->pushHandler($chromeHandler = new ChromePHPHandler());
                $chromeHandler->setFormatter(new ChromePHPFormatter());
            }
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Route.php

Route::get('/', function () {

    Log::info('General information log');

    return view('foundation.score');
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire