Bird
0
0

Which of the following is the correct way to define a single log channel in Laravel's config/logging.php?

easy📝 Configuration Q12 of 15
Laravel - Configuration and Environment
Which of the following is the correct way to define a single log channel in Laravel's config/logging.php?
A'single' => ['driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug']
B'single' => ['driver' => 'file', 'path' => 'storage/logs/laravel.log', 'level' => 'info']
C'single' => ['driver' => 'stack', 'channels' => ['daily'], 'level' => 'error']
D'single' => ['driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'days' => 7]
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct driver and keys for single channel

    The 'single' channel uses 'driver' => 'single', a 'path' with storage_path helper, and a 'level' key.
  2. Step 2: Check options for syntax and correctness

    'single' => ['driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug'] matches correct syntax. 'single' => ['driver' => 'file', 'path' => 'storage/logs/laravel.log', 'level' => 'info'] uses wrong driver 'file'. 'single' => ['driver' => 'stack', 'channels' => ['daily'], 'level' => 'error'] uses 'stack' driver incorrectly. 'single' => ['driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'days' => 7] misses 'level' key and has wrong driver.
  3. Final Answer:

    'single' => ['driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug'] -> Option A
  4. Quick Check:

    Single channel = driver 'single' + path + level [OK]
Quick Trick: Single channel uses driver 'single' with path and level keys [OK]
Common Mistakes:
  • Using 'file' instead of 'single' as driver
  • Confusing 'stack' driver with 'single'
  • Omitting required keys like 'level'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes