Laravel - Logging - Contextual Information

An array of contextual data may be passed to the log methods. This contextual data will be formatted and displayed with the log message:

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

Occasionally, you may wish to specify some contextual information that should be included with all subsequent log entries. For example, you may wish to log a request ID that is associated with each incoming request to your application. To accomplish this, you may call the Log facade's withContext method:

            return $next($request)->header('Request-Id', $requestId);