Symfony记录

Mat*_*ger 3 php logging symfony1

在Java中,我使用log4J作为日志框架.在Log4j中,您可以执行以下操作:

if (log.isDebug()) {
  // do some expensive operation that should only be displayed if DEBUG is turned on
}
Run Code Online (Sandbox Code Playgroud)

阅读一些Symfony示例,我无法找到确定是否在当前类上下文中激活DEBUG日志记录的方法.有没有办法做到这一点?

if (--need something here--) {
  $this->logMessage('Expensive operation return value: '.expensiveFunction(), 'debug');
}
Run Code Online (Sandbox Code Playgroud)

ax.*_*ax. 5

就像是

$this->getLogger()->getLogLevel() == sfLogger::DEBUG
Run Code Online (Sandbox Code Playgroud)

应该做.