1

I would like to know how to log messages in custom module install script.

File path:

app/code/local/Namespace/Modulename/sql/modulename_setup/mysql4-install-0.0.1.php

The script is running fine. I'm able to debug the file and see the SQL error, moreover, core_resource table is updated properly but the message under the catch block is not logged at:

var/log/modulename_setup.log

My script:

<?php

try {
    $installer = $this;
    $installer->startSetup();
    $installer->run("
       CREATE TABL 'dummy_table' (
        'id' int(11) unsigned NOT NULL auto_increment,
         PRIMARY KEY ('id')
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    ");
    $installer->endSetup();
} catch(Exception $e) {
    Mage::log('Something went wrong.', null, 'modulename_setup.log');
}

?>

Any suggestions?

3

Yes I faced the problem before, the only way I managed to get it working was by forcing the log by setting the 4th parameter of Mage::log to true so in your case I suggest you use the following code

Mage::log('Something went wrong.', null, 'modulename_setup.log', true);
  • @brunof feel free to mark your question as answered so it will benefit for others – Raphael at Digital Pianism May 23 '16 at 18:30
  • I've tried but I'm not able because my reputation is under 15 points. =( – brunof May 23 '16 at 19:15
  • @brunof you don't need to upvote to mark your question as answered you should be able to click the tick mark next to my answer can't you? – Raphael at Digital Pianism May 23 '16 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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