1

We've recently inherited a mess of a Magento store with a new client that has come to us and there are thousands of DEBUG entries being written to log every minute.

They don't give a lot to go on from what is being written to log (below screenshot) and just wondered what the quickest way you could recommend would be, to track down just where these are coming from in the system?

Short of searching for Mage::log() or running a diff check on the entire site, I am unsure what else I can try.

Debug entries written to Magento log

4

Find out which URL is triggering the log

Edit app/Mage.php and replace the following code under the log() method:

$loggers[$file]->log($message, $level);

With:

$loggers[$file]->log(self::$_app->getRequest()->getControllerName(), $level);
$loggers[$file]->log(self::$_app->getRequest()->getActionName(), $level);
$loggers[$file]->log(self::$_app->getRequest()->getRouteName(), $level);
$loggers[$file]->log(self::$_app->getRequest()->getModuleName(), $level);
$loggers[$file]->log($message, $level);

This should help you find out the location of the problem.

The hard way

Assuming you haven't rewritten any core files you can do the following in your console:

cd app/code/community
grep -ri "mage::log(" .
cd ../local
grep -ri "mage::log(" .
cd ../../design
grep -ri "mage::log(" .

This should give you a good list on where to look.

The softer hard way ^^

Open app/Mage.php and rename the log function with something else, example:

public static function nolog($message, $level = null, $file = '', $forceLog = false)

Reload your page you will get an exception such as:

Fatal error: Call to undefined method Mage::log() in /path/to/the/file/calling/the/log/function

With a full stack trace.

This way you will get directly which file is trying to call the Mage::log() method.

  • Thanks for clarifying, I actually tracked down the screenshot in my question quite quickly just by searching for Mage::log( but some of these others are proving much more difficult :/ – zigojacko Mar 25 '16 at 10:45
  • The next one is proving difficult (tried a search in all code pools but could not see the cause) - the path to every used .xml file is being logged (not on every page load, not sure which page load). – zigojacko Mar 25 '16 at 12:15
  • @zigojacko I've found another way of doing it check my updated answer – Raphael at Digital Pianism Mar 31 '16 at 15:26
  • 1
    Finally got round to trying your second solution but if I think what you're saying is that this requires a refresh of the page in the frontend to throw the stack trace? Which if is the case, I can't because I have no idea what URL's or process is causing all the DEBUG entries in the system.log. I tried reloading the homepage, categories, products, CMS pages, checkout after modifying the log function to nolog but did not see any new or useful information unfortunately. – zigojacko Apr 4 '16 at 12:18
  • 2
    Bingo!! Finally found it. Core file had been edited with Mage::log($filename); in /app/code/core/Mage/Core/Model/Layout/Update.php around line 450 (Magento CE 1.9.2.1). Wow, that was a mission - thanks for all your help @Raphael. – zigojacko Apr 8 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.