monolog.php 749 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use Symfony\Component\Config\Resource\ClassExistenceResource;
  3. use Symfony\Component\Console\Application;
  4. $handlers = [
  5. 'main' => [
  6. 'type' => 'fingers_crossed',
  7. 'action_level' => 'error',
  8. 'handler' => 'nested',
  9. ],
  10. 'nested' => [
  11. 'type' => 'stream',
  12. 'path' => '%kernel.logs_dir%/%kernel.environment%.log',
  13. 'level' => 'debug',
  14. ],
  15. ];
  16. $container->addResource(new ClassExistenceResource(Application::class));
  17. if (class_exists(Application::class)) {
  18. $handlers['console'] = [
  19. 'type' => 'console',
  20. 'process_psr_3_messages' => false,
  21. 'channels' => ['!event', '!doctrine'],
  22. ];
  23. }
  24. $container->loadFromExtension('monolog', [
  25. 'handlers' => $handlers,
  26. ]);