Magento Logs – Developers First Love

/
/
/
150 Views

If you want to debug any module and functionality you want to find the log.Every developers love the logs.

magento logs

While working with magento extension development or customization you need to check the magento log.I will guide you  that

1.How to active magento log from settings.

2.How to write into magento logs.

3.Where to find the magento log file.

If you want to active/disable the magento log then go to the magento admin and follow the following setting

magento logsSystem->Configuration -> Developer -> Log Setting -> Enabled ->Yes

If your website is in production mode then i suggest you that keep disabled the magento logs to speed up your website.

Magento logs function with all parameters

public static function log($message, $level = null, $file = ”, $forceLog = false)
Here are all the parameters of magento log function

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

If you want to write data or information in logs from any controller ,model or viewer you can use the following code.

Mage::log(‘my first debug line’); // for your custom message
Mage::log(print_r($data));        // for print your data array
Mage::log($data);                      // for print any variable
Mage::log(‘debug for my log file’, null, ‘mylog.log’);            // for your custom message in your own log file

All the logs file are store under tha /var/log folder of magento root directory.you can find the your created logs files here and you can debug the data and bugs or error.

 

 

Sign up for our newsletter to get Daily Updates

It is main inner container footer text