Laravel Logging: Writing Log Messages

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

namespace App\Http\Controllers;

use App\User;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return Response
     */
    public function showProfile($id)
    {
        Log::info('Showing user profile for user: '.$id);

        return view('user.profile', ['user' => User::findOrFail($id)]);
    }
}

By default, the message will be written to the default log channel as configured by your config/logging.php configuration file.

Contextual Information

Log::info('User failed to login.', ['id' => $user->id]);

Writing To Specific Channels

Log::channel('slack')->info('Something happened!');
Log::stack(['single', 'slack'])->info('Something happened!');

Laravel Logging: Writing Log Messages — Structure map

Clickable & Draggable!

Laravel Logging: Writing Log Messages — Related pages: