在 Java 中,我使用log4J,它是一个日志框架。在 Log4j 中,您可以执行以下操作:
if (log.isDebug()) {
// do some expensive operation that should only be displayed if DEBUG is turned on
}
阅读一些 Symfony 示例,我无法找到一种方法来确定是否在当前类上下文中激活了 DEBUG 日志记录。有没有办法做到这一点?
if (--need something here--) {
$this->logMessage('Expensive operation return value: '.expensiveFunction(), 'debug');
}