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() {

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



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

does not work either

  • Is logging enabled in system configuration? Is var/log/ writable by your web user (apache, httpd, www-data, etc.)
    – laketuna
    Commented May 22, 2015 at 13:39
  • logging works in SitemapController.php, so yes, it is. and yes var/log is writable. Thanks for your ideas
    – Yorrd
    Commented May 22, 2015 at 13:42
  • Perhaps Mage core isn't loaded? Maybe try Mage::app() Commented May 24, 2015 at 0:08
  • @TimHallman how would magento work without core? The site works just fine
    – Yorrd
    Commented May 25, 2015 at 14:05
  • Because it's sitemap.php. Try logging in app/code/local/Mage/Sitemap/Model/Observer.php rather than Sitemap.php Commented May 25, 2015 at 15:12

5 Answers 5


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

  • Yes. Thanks. I guess I'll open another question why my generateXml is not loaded. Because no, it does not reach the breakpoint.
    – Yorrd
    Commented May 29, 2015 at 8:53

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

  • Or for instance a sitemap.log in case you don't want your sitemap logs mixed with random stuff . Commented May 29, 2015 at 8:24
  • @JulienLachal. True. The filename can be anything.
    – Marius
    Commented May 29, 2015 at 8:32
  • please see my edit, this does not work either
    – Yorrd
    Commented May 29, 2015 at 8:36

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.

  • True, but I'm testing it by just clicking "generate" on the sitemap admin page. So I'd assume he should have permission. EDIT: it does not work either if the permission is set to 777
    – Yorrd
    Commented May 29, 2015 at 8:38

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


hope it will work for you.

Your Answer

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

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