I'm having this weird issue that both of my custom plugin logs are not working but all other third party ones including craft.log work fine. By 'not working' I mean the log file is generated, but empty.

Another weird thing is the issue only happens on production environment. Tested on local environment and staging environment, they all work fine.

I believe I got the code right?

MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error);

It's Craft 2 by the way.

Anything ideas?

  • Weird... I'm assuming devMode is not enabled in production. Is it locally and in staging?
    – Brad Bell
    Nov 28 '18 at 6:30
  • devMode is enabled locally, but disabled on staging and production. Weird, huh? Anyway, forcing log param did the trick.
    – Wei
    Dec 3 '18 at 4:32

Put the force parameter to true

MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error, true);

Custom Log in Craft

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.