By default Magento logs notices, warnings and errors into the system.log file. Is it possible to restrict the log level so that Magento doesn't log PHP notices?
Magento's Mage::log() method offers the option to set the log level by providing, e.g. Zend_Log::DEBUG as a parameter, and it'd be great to suppress logging of PHP notices.
ps. I do know that fixing the code producing the errors would be recommended, but the errors originate from third-party code and extensions, so that'd be impossible to manage.
2 Answers 2
I think you'd like to set the level to Zend_Log::WARN, according to 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
As I see you cannot and won't go through the 3rd party code and set this globally, you could try to adjust the PHP error reporting this way:
error_reporting(E_ALL ^ E_NOTICE);
I didn't test it but maybe it helps to get rid of the entries in the log.
-
1Adding
error_reporting(E_ALL ^ E_NOTICE);to the index.php file did work. Easier than expected, but since the PHP notices originated from Apache, that's the way to go without having to modify third-party code.oschloebe– oschloebe2013年09月02日 15:39:32 +00:00Commented Sep 2, 2013 at 15:39
For advanced logging capabilities, take a look at https://github.com/magento-hackathon/Logger
-
1Which has moved to Firegento Logger: github.com/firegento/firegento-loggerSPRBRN– SPRBRN2014年05月05日 10:58:19 +00:00Commented May 5, 2014 at 10:58
-
both outdated / not existing anymore (2016)Barbarossa– Barbarossa2016年12月13日 13:33:59 +00:00Commented Dec 13, 2016 at 13:33
-
The second isn't? github.com/firegento/firegento-loggerPaul Hachmang– Paul Hachmang2016年12月13日 15:27:33 +00:00Commented Dec 13, 2016 at 15:27