Home / Snippets / How to log with parameters in Laravel 8
How to log with parameters in Laravel 8 cover

How to log with parameters in Laravel 8

806

3 years ago

0 comments

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']);
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this