0

I am trying to understand following code (it is from Data.php). I am assuming it creates some sort of log file, but i can not figure out where can i find it. Can any one help me please? (It does not create file erply.log - i have searched it from all the directories).

class Eepohs_Erply_Helper_Data extends Mage_Core_Helper_Data {
 private $_filename = 'erply.log';
 public function log($message, $method = null, $line = null) {
  if ( Mage::getStoreConfig('eepohs_erply/general/log_enabled') ) { 
   if ( is_null($method) ) $method = __METHOD__;
   if ( is_null($line) ) $line = __LINE__; Mage::log(sprintf('%s(%s): %s', $method, $line,
   print_r($message, true)), null, $this->_filename); 
  }
 }
}

All the files associated with it are located in https://github.com/erplyopensource/magento-integration (i am just trying to understand the code)

0

3 Answers 3

0

I want to add some information here

First look at

Mage::log(sprintf('%s(%s): %s', $method, $line,  print_r($message, true)), null, $this->_filename)

As per as this code their are 3 parameters sended to log() function

  • message
  • level
  • log file name

But in Mage::log() function there are 4 parameters on function

public static function log($message, $level = null, $file = '', $forceLog = false)
    {
      ....
        try {
            $logActive = self::getStoreConfig('dev/log/active');
            if (empty($file)) {
                $file = self::getStoreConfig('dev/log/file');
            }
        }
        catch (Exception $e) {
            $logActive = true;
        }

        if (!self::$_isDeveloperMode && !$logActive && !$forceLog) {
            return;
        }
.......
      }

and 4th params is forceLog, which create log file forcefully even Configuration->Developer->Log settings->Enabled is No..

As you did not send this parameter that value is set as false to this and as you disabled the log setting that it does not create log file.So need to enable this setting.

if you want create log which does not depends on log setting then send 4th parameter as true and also set a custog file name

Mage::log(sprintf('%s(%s): %s', $method, $line,  print_r($message, true)), null, 'custom.log',true) 
1

The Magento log uses self::getBaseDir('var') . DS . 'log' as a directory to log to. This means it's in your Magento installation's folder in var/log.

In this case the filename is parsed as a 3rd argument: erply.log. So the path should be var/log/erply.log.

If you're not seeing any logs check the following

  1. The var/log dir is writable (chmod 775 and the right owner)
  2. System > Configuration > Developer > Logsettings has logging turned on
1

Solved: Configuration->Developer->Log settings->Enabled: Yes

The file appears then in the var/log directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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