1

I am making a plugin which has a controller to be called every hour.
My server environment is using Anacron.

So I wrote this anacron job:
1@hourly 0 cron.hourly wget http://www.mydomain.com/actions/controlername

And I got 2 questions:

  1. How to log my cron job into a file on the server? (so I can follow when it has been triggered)
  2. What is the best way to log and follow my controller actions in Craft CP side?
4

In answer to your second question:

  1. What is the best way to log and follow my controller actions in Craft CP side?

You can log actions to a plugin-specific log file like this:

MyPluginNamePlugin::log('Controller action triggered', LogLevel::Info, true);

Setting the third parameter to true forces the logging to happen, even if you are not in devMode.

The log file can be found in the craft/storage/runtime/logs/ directory and will be called mypluginname.log.

To view logs in the CP visit /admin/utils/logs

|improve this answer|||||

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.