Magento 1.9.1 – System and Exception Log Not Working

ce-1.9.1.0debugginglog

I have exhausted every trick in my book. Magento will not log anything at all, to debug I inserted two log calls in index.php

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
    Mage::log("WOOOOPIE");
    error_log("Go sell your fur");
}
  • php error_log works and logs to /var/log/apache2/error.log
  • {{Magento dir}}/var/log/system.log and exception.log are empty.
  • In the Admin panel, Under Configuration > Developer, I enabled profiler and error logging.
  • The entire var directory is owned by www-data and chmod'ed 777, I checked ps aux and envvars to confirm apache is running as www-data.
  • All caches were cleared repeatedly, then disabled.
  • index.php has the default of error_reporting(E_ALL | E_STRICT); set.

Here are the permissions of system.log, I had to touch it myself.

namei -ml /var/www/nslocal/var/log/system.log`
f: /var/www/nslocal/var/log/system.log
drwxr-xr-x root     root     /
drwxr-xr-x root     root     var
drwxrwxr-x root     www-data www
drwxrwxr-x www-data ci       nslocal
drwxrwxrwx www-data ci       var
drwxrwxrwx www-data ci       log
-rwxrwxrwx www-data ci       system.log

I have even tried restarting. Without the log working I can't debug why magento isn't sending emails, despite php and sendmail working properly. Do I have a ghost?

Best Answer

From what I understand, the Mage logger will not function so early in the application spin up.

If you look at the Mage::log function itself, you'll find:

if (!self::getConfig()) { return; }

As Mage::getConfig() will return null until the application's config is initialised later on inside the Mage::run() function, the Mage::log function will exit without doing anything when called from index.php.

To test the logging is actually working, try placing your test later on, perhaps in Mage_Core_Controller_Varien_Front::dispatch which works for me.

Related Topic