Symfony Logging

In Java, I use log4J that is a logging framework. In Log4j you can do something like this:

if (log.isDebug()) {
  // do some expensive operation that should only be displayed if DEBUG is turned on

Reading some Symfony examples, I am unable to find a way to determine if DEBUG logging is activated in the current class context. Is there a way to do this?

if (--need something here--) {
  $this->logMessage('Expensive operation return value: '.expensiveFunction(), 'debug');


something like

$this->getLogger()->getLogLevel() == sfLogger::DEBUG

should do.

You should check the usage for Monolog

You could also try: sfConfig::get('sf_logging_enabled'). It shows if logging is enabled. The levels can be configured in the factories.yml.

You can check is in debug mode with that:

if ($this->get('kernel')->isDebug()) {

This is information about logger service and

you can use the symfony logger service if your are in a controller you can call this service using this code:

if ($this->get('kernel')->isDebug()) {
 $this->get('logger')->err('my custom message');

If you want to improve your system yo can check MonologBundle

Need Your Help

php xpath returns node value as Array

php xml arrays xpath

Im using xpath to get values for a cms page,

Is there a way to copy a source code build of Qt to another location?

qt build-automation

We're building a Windows and Mac app using a commercial licence of Qt, which we're building from a git clone.