0

I need help. I am using Monolog logger.

use Monolog\Logger;

$logger = new Logger('app');
$logger->pushHandler(new StreamHandler(\dirname(__DIR__, 2) . '\\var/log/dev.log', Logger::DEBUG));
$logger->pushHandler(new FirePHPHandler());

$logger->info('My logger is now ready');

The problem is that the log is written to the file, but it is not visible in the Symfony profile.

what needs to be done so that the logs are displayed in the Symfony profile??

Mikhail Prosalov
  • 4,155
  • 4
  • 29
  • 41
Pr9nik
  • 1
  • 1
  • Is it possible that your logs are on another request? If you go to "last 10", do you see it? – Julien B. Jun 14 '20 at 15:04
  • why do you dont use the ` LoggerInterface` provided by Symfony itself? Instead of settiging up a logger which should be allready configured and present? – Rufinus Jun 14 '20 at 16:55
  • @Rufinus I want a static method "log($text)" so it doesn't suit me LoggerInterface. LoggerInterface i can use in controllers which are extends AbstractController.. – Pr9nik Jun 15 '20 at 20:39
  • @JulienB. no..i sorted the logs by channel and i dont see them. but they are in the file (var/log/dev.log) – Pr9nik Jun 15 '20 at 20:44
  • Is the file with the code you shared executed inside Symfony? – Julien B. Jun 15 '20 at 22:29
  • 1
    `LoggerInterface` is not only usable in controllers which extends `AbstractController`. You just have to use dependency injection to get it everywhere. [Symfony documentation - Dependency injection](https://symfony.com/doc/current/components/dependency_injection.html) – D. Schreier Jun 16 '20 at 10:10
  • @JulienB. Yes, i use logger in class MessageHandler implements MessageComponentInterface – Pr9nik Jun 17 '20 at 10:09

0 Answers0