I've created my own cron job in Magento that is executed every day at the beginning of the day where I have my business logic, the goal of this cron job is import external data and insert in the magento database and I need to have a log there to register each record that has been inserted/updated/deleted and register if something went wrong, as this process is too long I want to have one log per each day.

So in my observer method I've put something like this:

public function importCron()

    $filename = date('Y-m-d') . "-import.log";
    $startDate = date('Y/m/d H:i:s');
    $emailTemplateVariables["startDate"] = $startDate;
    Mage::log("Import STARTED on " . $startDate, 7, $filename);

    // {
    //  Bussiness logic here
    // }

In the above code I want to create a new log file using the date as part of the name so each time that my cron will be executed it will generate a new log file using the date.

But now my problem is that the log file isn't created when the cron runs, I've set all the permissions to the folder in order to test, but nothing is created when the cron runs; the weird thing is that I'm using Aoe_Scheduler extension to run my cron manually and in this case the log file is created.

  • When you have enabled your system logs, what scope is it "Enabled" under? It could be because the two scripts run under different scopes Jun 14, 2016 at 15:48
  • That's a global configuration so I have it enabled globally. Jun 14, 2016 at 16:00
  • Is the user that runs the con manually the same that runs the cron ?
    – tehknox
    Jun 14, 2016 at 16:08

1 Answer 1


This might be problem of scope where you enabled the logs. Please pass one more parameter (true) to log function call like below:-

Mage::log("Import STARTED on " . $startDate, 7, $filename, true);

Now it will not check configuration whether you have enabled the log or not.


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.