9951 explained code solutions for 126 technologies


php-symfonyHow to set the log level in PHP Symfony?


The log level in PHP Symfony can be set by using the logger service.

$logger = $this->get('logger');
$logger->setLevel(Logger::ERROR);

The above code sets the log level to ERROR.

The following are the available log levels in PHP Symfony:

  • Logger::EMERGENCY: System is unusable
  • Logger::ALERT: Action must be taken immediately
  • Logger::CRITICAL: Critical conditions
  • Logger::ERROR: Error conditions
  • Logger::WARNING: Warning conditions
  • Logger::NOTICE: Normal but significant condition
  • Logger::INFO: Informational messages
  • Logger::DEBUG: Debug-level messages

Helpful links

Edit this code on GitHub