I need to override format log on project made with Laravel 5.3
I use as a guide this post but does not work.
First create a bootstrap/ConfigureLogging.php class
<?php
namespace Bootstrap;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger as Monolog;
use Monolog\Formatter\LineFormatter;
use Illuminate\Log\Writer;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as BaseConfigureLogging;
use Monolog\Handler\StreamHandler;
use Carbon\Carbon;
class ConfigureLogging extends BaseConfigureLogging
{
/**
* Configure the Monolog handlers for the application.
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureDailyHandler(Application $app, Writer $log)
{
$config = $app->make('config');
$maxFiles = $config->get('app.log_max_files');
// Formatting
// the default output format is "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
$logFormat = "[%datetime%] [%level_name%]: %message% %context% %extra%\n";
$formatter = new LineFormatter($logFormat);
//$logStreamHandler->setFormatter($formatter); // Here I'm lost
$log->useDailyFiles(
$app->storagePath().'/logs/cprsync.log', is_null($maxFiles) ? 5 : $maxFiles, $config->get('app.log_level', 'debug')
);
}
This change (override) name of laravel logs for my app. But when I try to add code for override format, I'm lost, and code on original post not work.
I see code for Monolog, and I see that I need send my format, but I don't know.
The link you are referring should work to my knowledge. You are missing
pushHandler