spacecodeur
spacecodeur

Reputation: 2406

Symfony 4, how print logs in profiler log page?

From php files in Symfony 4, how can I print variables (for debug) to the log profiler page ?

I mean this page :

enter image description here

I tried that :

$log = new Logger()
$log->info("test");

$log2 = new ConsoleLogger(OutputInterface::OUTPUT_NORMAL);
$log2->alert("hello !");

But nothing appears...

Upvotes: 2

Views: 2626

Answers (2)

bderidder
bderidder

Reputation: 51

You may not have installed the monolog bundle. Without that you get a very rudimentary logging.

Run:

composer require symfony/monolog-bundle

Reload app and see if message start appearing in the log tab of the profiler.

Upvotes: 3

spacecodeur
spacecodeur

Reputation: 2406

I just follow the monolog symfony guide : http://symfony.com/doc/current/logging.html

After logger install, I add somewhere in a controller a "$logger->info("foo");" and I see the trace from the log profiler page

Upvotes: 0

Related Questions