默认情况下,Magento日志记录通知,警告和错误 system.log 文件。是否可以限制日志级别,以使Magento不会记录PHP通知?

Magento的 Mage::log() 方法提供了通过提供来设置日志级别的选项,例如 Zend_Log::DEBUG 作为一个参数,可以抑制PHP通知的记录非常好。

PS。我确实知道,建议修复产生错误的代码,但错误源于第三方代码和扩展名,因此无法管理。

有帮助吗?

解决方案

我想你想设定 Zend_Log::WARN, , 根据 Zend_Log:

const EMERG   = 0;  // Emergency: system is unusable
const ALERT   = 1;  // Alert: action must be taken immediately
const CRIT    = 2;  // Critical: critical conditions
const ERR     = 3;  // Error: error conditions
const WARN    = 4;  // Warning: warning conditions
const NOTICE  = 5;  // Notice: normal but significant condition
const INFO    = 6;  // Informational: informational messages
const DEBUG   = 7;  // Debug: debug messages

当我看到您不能也不会浏览第三方代码并在全球设置此设置,因此您可以尝试调整以这种方式报告的PHP错误:

error_reporting(E_ALL ^ E_NOTICE);

我没有测试它,但也许有助于摆脱日志中的条目。

其他提示

对于高级记录功能,请看一下 https://github.com/magento-hackathon/logger

许可以下: CC-BY-SA归因
scroll top