Question

I have overwritten Sitemap.php in app/code/local/Mage/Sitemap/Model/Sitemap.php. The file seems to be used, if I remove all contents, there's an error as expected.

I copied the complete content of the standard Sitemap.php, with one single change. I added

public function generateXml() {
    Mage::log('test');
    ...
}

When I do this anywhere else, it prints test in var/log/system.log as expected, only in this file, it does not log the message.

Any help is greatly appreciated


EDIT

using

Mage::log('text', null, <file>, true);

does not work either

Was it helpful?

Solution

I would assume, the file is loaded but the method is not called. So just set a breakpoint (or bad way a die()) into your method and make sure it is called.

After magento is initialized Mage::log at least with the $force parameter writes its log

OTHER TIPS

Use Mage::log('text here', null, 'system.log', true).
That should work all the time.

Another guess here - the sitemap generation is generally triggered by a cronjob. If your cronjob runs under a different user than your webuser and doesn't have the permissions to write to your existing system.log file you wouldn't get any entries.

Give the right permit to your var/ folder:

chmod -Rv 777 var/

So use like this code below:

Mage::log(print_r($yourTest), null, 'customLogFile.log', true);

The print_r will prevent some errors related to the type of your variable.

Put this line in any function or file

Mage::log( "Your message - ", null, 'your-log-filename.log');

this file will be created at your inside your root folder path like

/var/log/your-log-filename.log

hope it will work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top