Can we create a custom log file for different purposes in laravel 5.2 like for order related log entries that should be in order.log and for payment related stuff the entry shou
You can try repurposing the log functions to write different types of logs to different files. This can be done by editing the bootstrap/app.php
file:
$app->configureMonologUsing(function($monolog) {
$bubble = false;
$infoStreamHandler = new Monolog\Handler\StreamHandler( storage_path("/logs/orders.log"), Monolog\Logger::INFO, $bubble);
$monolog->pushHandler($infoStreamHandler);
$warningStreamHandler = new Monolog\Handler\StreamHandler( storage_path("/logs/logins.log"), Monolog\Logger::WARNING, $bubble);
$monolog->pushHandler($warningStreamHandler);
});
Then in your code, you can do:
Log::info('Order was created', ['ORDER-123']);
Log::warning('User login', ['USER-1']);
You can use this method to edit all the available log functions: