laravel 5.2 cannot print log on stdout

9/27/2020

I add this on my bootstrap/app.php:

$app->configureMonologUsing(function(\Monolog\Logger $monolog) {
    $formatter = new \Monolog\Formatter\LineFormatter(null,null,false,true);
    $stdOut = new \Monolog\Handler\StreamHandler('php://stdout',\Monolog\Logger::DEBUG);
    $stdOut->setFormatter($formatter);
    $monolog->pushHandler($stdOut);

    $file = storage_path('logs/mono-'. Date('Y-m-d', time()) . '.log');
    $monolog->pushHandler(new \Monolog\Handler\StreamHandler($file));

});

PhpVersion:5.6

LaravelVersion:5.2

Env:3.10.0-1062.18.1.el7.x86_64

Env is a docker pod.

But it cannot not print log on stdout. No log found out. Is there someone know how to fix this.

-- Io Wu
kubernetes
laravel
php
stdout

1 Answer

9/27/2020

by the way, Laravel 5.2 has a built-in logger:

Log::info($YOUR_VARIABLE); (or \Log::info($YOUR_VARIABLE);)

read the documentation carefully: https://laravel.com/docs/5.2/errors#introduction

-- ktscript
Source: StackOverflow