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?

1 Answer 1

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);
3
  • @brunof feel free to mark your question as answered so it will benefit for others Commented May 23, 2016 at 18:30
  • I've tried but I'm not able because my reputation is under 15 points. =( Commented May 23, 2016 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? Commented May 23, 2016 at 19:32

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.