6

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.

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Sep 2, 2013 at 12:05

2 Answers 2

7

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.

answered Sep 2, 2013 at 13:57
1
  • 1
    Adding 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. Commented Sep 2, 2013 at 15:39
2

For advanced logging capabilities, take a look at https://github.com/magento-hackathon/Logger

answered Sep 2, 2013 at 12:17
3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.