Posts Learn Components Snippets Categories Tags Tools About
/

How to log with parameters in Laravel 8

Learn how to pass parameters when logging messages in Laravel to provide more data

Created on Aug 11, 2021

786 views

In Laravel, you can log messages using the Log facade. There are 8 types of logs depending on the situation and below is the list of the available logs in Laravel.

All Type of Logs in Laravel
use Illuminate\Support\Facades\Log;

Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);

Passing Parameters to Logs
To pass parameters when logging data you can pass an array as the 2nd parameter. You can pass any number of key-value pairs as necessary.
Log::alert('Some alert message mere', ['hello' => 'world']);
Log::info('Some info message mere', ['hello' => 'world']);

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for How to log with parameters in Laravel 8

)