Bird
0
0

You want to create a custom logging channel in Laravel that writes logs to a daily rotating file and also sends critical errors to Slack. Which configuration correctly combines these requirements?

hard📝 Workflow Q15 of 15
Laravel - Configuration and Environment
You want to create a custom logging channel in Laravel that writes logs to a daily rotating file and also sends critical errors to Slack. Which configuration correctly combines these requirements?
A'custom' => ['driver' => 'stack', 'channels' => ['single'], 'ignore_exceptions' => true], 'single' => ['driver' => 'single', 'path' => storage_path('logs/custom.log'), 'level' => 'debug']
B'custom' => ['driver' => 'daily', 'path' => storage_path('logs/custom.log'), 'level' => 'critical', 'days' => 14], 'slack' => ['driver' => 'stack', 'channels' => ['daily'], 'url' => env('LOG_SLACK_WEBHOOK_URL')],
C'custom' => ['driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'level' => 'debug'], 'daily' => ['driver' => 'daily', 'path' => storage_path('logs/custom.log'), 'level' => 'critical', 'days' => 7],
D'custom' => ['driver' => 'stack', 'channels' => ['daily', 'slack'], 'ignore_exceptions' => false], 'daily' => ['driver' => 'daily', 'path' => storage_path('logs/custom.log'), 'level' => 'debug', 'days' => 14], 'slack' => ['driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'level' => 'critical', 'username' => 'Custom Logger']
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirements for combined logging

    You need a stack channel combining 'daily' file logging and 'slack' for critical errors.
  2. Step 2: Check each option for correct driver and channel setup

    'custom' => ['driver' => 'stack', 'channels' => ['daily', 'slack'], 'ignore_exceptions' => false], 'daily' => ['driver' => 'daily', 'path' => storage_path('logs/custom.log'), 'level' => 'debug', 'days' => 14], 'slack' => ['driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'level' => 'critical', 'username' => 'Custom Logger'] correctly defines 'custom' as a stack channel with 'daily' and 'slack' channels. 'daily' logs debug and above, 'slack' logs critical only. Other options misuse drivers or channels.
  3. Final Answer:

    'custom' => ['driver' => 'stack', 'channels' => ['daily', 'slack'], 'ignore_exceptions' => false], 'daily' => ['driver' => 'daily', 'path' => storage_path('logs/custom.log'), 'level' => 'debug', 'days' => 14], 'slack' => ['driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'level' => 'critical', 'username' => 'Custom Logger'] -> Option D
  4. Quick Check:

    Stack channel combines daily + slack with correct levels [OK]
Quick Trick: Use stack driver to combine daily file and Slack channels [OK]
Common Mistakes:
  • Using wrong driver for stack channel
  • Misplacing Slack inside daily channel
  • Setting ignore_exceptions true when not needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes