WEB DEVELOPER SITE
TUTORIALS HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Laravel - Errors and Logging


Laravel - Errors and Logging :

Errors

when you begin another Laravel venture your Errors and exemption taking care of is as of now configured
We have to conceal these blunders from clients underway condition.
APP_DEBUG set in the earth document .env put away at the foundation of the application.
For nearby condition the estimation of APP_DEBUG ought to be valid yet for creation it should be set to false to conceal mistakes.

Logging

Logging is a critical instrument by which framework can log blunders that are created. It is valuable to enhance the unwavering quality of the system.
Laravel underpins diverse logging modes like single, every day, syslog, and errorlog modes. You can set these modes in config/app.php file.
'log' => 'every day' 

Creating a custom log file

To make a custom log document, you should make the accompanying strides −

Step 1 − In this progression, you ought to make a custom log document in Laravel utilizing the Log façade. The façade can be pronounced by basically utilizing the use watchword in controller. It is appeared as pursues −

<?php 

use Log; 

class LoginController extends Controller{ 

public function FuncName(Request $request){ 

//log something to capacity/logs/laravel.log 

Log::info(['Request'=>$request]);} 

} 

?>

Here, the capacity name FuncName will help in making logs by sending parameter Log::info inside the collection of function.

Step 2 − If there is a need to spare this record independently, you ought to do it at this progression. For this, you can utilize a demo work like useDailyFiles() just before the incorporation of log line as appeared here −

<?php 

use Log; 

class LoginController extends Controller{ 

public function FuncName(Request $request){ 

//log something to capacity/logs/debug.log 

Log::useDailyFiles(storage_path().'/logs/debug.log'); 

Log::info(['Request'=>$request]); 

} 

} 

?>

All the logs will be followed in record debug.log. The blunders noted in the logs will be helpful for development.

Step 3 − In this progression, you manage the lumberjack in Laravel, which incorporates different sorts separated from Log::info referenced in the precedent given.

Log::emergency($error); 

Log::alert($error); 

Log::critical($error); 

Log::error($error); 

Log::warning($error); 

Log::notice($error); 

Log::info($error); 

Log::debug($error);

The sorts of blunders which can be incorporated into the log documents are: emergency, alert, basic, mistake, cautioning, see, info and debug.