Skip to content

Print Instead Of Logger (ARCH7157)

Key php.logging.echo-instead-of-logger · Severity info · Category logging

Using echo, print, or var_dump for diagnostics instead of the framework logger makes output impossible to configure, level, or aggregate.

<?php
public function handle(Request $request): void
{
echo 'Processing request ' . $request->getId();
var_dump($request->all());
}
<?php
public function handle(Request $request): void
{
$this->logger->info('Processing request', ['id' => $request->getId()]);
}

Log through a PSR-3 logger at the appropriate level instead of writing to stdout.