Kshitij Soni
Kshitij Soni

Reputation: 394

Issue in set monolog in Laravel

I use this for logging . I tried to configure log rotation on but I'm stuck. I know how to do this with Laravel, I'm trying to create my own rotating log file in Laravel using Monolog, however, the file rotation is not working and I don't know why.

/* controller file */

use Illuminate\Http\Request;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;

public function getSheduled(){     
    $log = new Logger('getSheduled');
    $log->pushHandler(new RotatingFileHandler(storage_path().'/logs/cron_log/custom_log.log',2, Logger::INFO)); 
    $log->info(json_encode($followup_shedule_data));

}

It seemed pretty straightforward to me, but it's simply not working. The log files are being generated correctly but when When I see their output it give me like this:

/*text file */

    [2017-02-14 12:24:46] getSheduled.INFO: [] [] []

I don't want last 2 array from array.Please answer

Upvotes: 0

Views: 141

Answers (1)

Paras
Paras

Reputation: 9455

Change the code as follows:

$lineFormatter = new \Monolog\Formatter\LineFormatter(null, null, true, true);
$log = new Logger('getSheduled');
$log->pushHandler((new RotatingFileHandler(storage_path().'/logs/cron_log/custom_log.log',2, Logger::INFO))->setFormatter($lineFormatter)); 
$log->info(json_encode($followup_shedule_data));

Upvotes: 1

Related Questions