<p>Put the force parameter to true</p>

<pre><code>MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error, true);
</code></pre>

<p><a href="https://craftcms.stackexchange.com/questions/2895/custom-log-in-craft">Custom Log in Craft</a></p>

CC BY-SA 4.0
2018-11-28T08:28:08.527Z
2018-11-28T08:28:08.527Z
Wasnu
<p>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.</p>

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

<p>I believe I got the code right?</p>

<p><code>MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error);</code></p>

<p>It's Craft 2 by the way.</p>

<p>Anything ideas?</p>

CC BY-SA 4.0
2018-11-28T06:30:24.447Z
Weird... I'm assuming devMode is not enabled in production.  Is it locally and in staging?
Brad Bell
CC BY-SA 4.0
2018-12-03T04:32:49.813Z
devMode is enabled locally, but disabled on staging and production. Weird, huh? Anyway, forcing log param did the trick.
Wei
<craft2><logs><logging>
Custom plugin log not logging
# Custom plugin log not logging

(Asked by: username_0 on 2018-11-28)

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?

**Tags:** craft2, logs, logging

> **Comments:**
> **username_1**: username_0rd... I'm assuming devMode is not enabled in production.  Is it locally and in staging?  
> **username_0**: devMode is enabled locally, but disabled on staging and production. username_0rd, huh? Anyway, forcing log param did the trick.  

---

## 1 answers

### Answer by username_2 on 2018-11-28. Score: 2 | Accepted answer

Put the force parameter to true
MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error, true);

Custom Log in Craft


---

