laravel db log code example

Example 1: How to Log Query in Laravel

DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());

Example 2: laravel log

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);

Example 3: How to Log Query in Laravel

DB::enableQueryLog();
$user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());

Example 4: laravel log

use 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);

Tags:

Php Example