What is the Logging system in Laravel?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Laravel development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
Laravel's logging system is built on Monolog and configured via config/logging.php. Log messages with the Log facade using PSR-3 severity levels: Log::emergency(), Log::alert(), Log::critical(), Log::error(), Log::warning(), Log::notice(), Log::info(), Log::debug(). Add context data: Log::info("User logged in", ["user_id" => $user->id]). Channels: stack (combine multiple channels), single (one log file), daily (separate file per day), slack, syslog, errorlog, cloudwatch. Log to a specific channel: Log::channel("slack")->critical("Server is down!"). For production, use a dedicated logging service (Papertrail, Loggly, Sentry).
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Laravel answers easy to follow.