QA
Beginner LevelLaravel

How does Laravel Logging work using Monolog channels and stack configuration?

❓ Interview Prompt: Explain Log facade, Monolog channels (single, daily, slack, stderr), config/logging.php, and log levels.

Laravel uses Monolog to support flexible logging channels configured in 'config/logging.php'.

Channels & Levels:

•
Channels: 'single' (file), 'daily' (rotating date files), 'slack' (webhook notifications), 'stderr'.
•
Log Facade: Provides PSR-3 log levels: 'Log::emergency()', 'Log::error()', 'Log::warning()', 'Log::info()', 'Log::debug()'.

Code Implementation Example

php
<?php
use IlluminateSupportFacadesLog;

try {
    // ... database operation
} catch (Throwable $e) {
    Log::error('Payment processing failed', [
        'user_id' => $user->id,
        'error' => $e->getMessage(),
    ]);
}
💡Logging error messages with contextual payload data using Log facade.
🎯 Interview Key Takeaway

Use Log facade methods with contextual array payloads to output structured logs across Monolog channels.

#Logging#Monolog#Log Facade#Beginner
Back to all Laravel Questions→

More Laravel Interview Questions

Beginner LevelLaravel

How does the Laravel Service Container manage Dependency Injection and Bindings?

Beginner LevelLaravel

How does Routing work in Laravel including Named Routes and Route Parameters?

Beginner LevelLaravel

What is Blade Templating and how do custom directives work?