Answers.Body: <blockquote>
  <p>If you want a log item to appear regardless of whether devMode is enabled, you can pass true as the third argument to the log() method.</p>
  <p>Is this accurate?</p>
  </blockquote>
  <p>Yes. Logs will only get flushed to disk is a proper <code>craft()-&gt;end()</code> occurs, firing the <code>onEndRequest</code> event.  So if you're doing something in your plugin like calling PHP's <code>exit()</code> directly or there is some other logic that inadvertently kills the request, then they won't get written to the log file.</p>
  <p>I'd suspect that's what you're running into.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T21:17:39.137Z
Answers.Text: Would the logs output fine with dev mode true? Because they do. I am trying to output logs from the Import `modifyImportRow` hook regardless of dev mode.
Answers.UserDisplayName: Steve Mock
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T23:21:24.497Z
Answers.Text: And you're looking in `craft/storage/runtime/logs/sproutactive.log`?  I just tested this in a test plugin's init method with `TestPlugin::log('Log this with or without devMode enabled.', LogLevel::Info, true);` and devMode disabled and got the expected `2016/09/13 23:19:27 [info] [plugin] [Forced] Log this with or without devMode enabled.` in `test.log`.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-14T00:55:00.340Z
Answers.Text: Yes, of course. If it ever gets written. But it doesn't. Something is screwy with the Import plug-in I think.
Answers.UserDisplayName: Steve Mock
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-14T01:10:49.787Z
Answers.Text: I tried - as you - putting the line into the Import plug-in init method, and indeed works as expected. So something else is happening. Thanks for helping.
Answers.UserDisplayName: Steve Mock
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-14T02:59:40.257Z
Answers.Text: Yeah, my guess is something in the plugin is improperly ending the request not giving Craft a chance to flush the logs. Still weird that it works fine with devMode on, though.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T21:07:44.737Z
Answers.LastActivityDate: 2016-09-13T21:07:44.737Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: Brad Bell
Body: <p>Unfortunatley we need to develop an Import plug-in helper with dev mode OFF, for - according to Brad at P&amp;T:</p>
  
  <blockquote>
    <p>devMode uses a lot more memory on a given PHP request and importing
    probably already requires significant memory, so my guess is that
    you're running into your php.ini file's memory_limit or
    max_execution_time limits or something similar.</p>
  </blockquote>
  
  <p>The Import plug-in is definitely a resource pig. We can't get it to work <em>at all</em> in dev mode. But we need to develop a plug-in using its hooks to help with things it can't handle in our situation (tables, dates, switches) so we're in a tough spot.</p>
  
  <p>According to <a href="https://straightupcraft.com/articles/how-do-i-log-errors-warnings-and-info-in-my-plugins-to-a-craft-log-file" rel="nofollow">this</a> article:</p>
  
  <blockquote>
    <p>If you want a log item to appear regardless of whether devMode is
    enabled, you can pass true as the third argument to the log() method.</p>
  </blockquote>
  
  <pre><code>SproutActivePlugin::log('Log this with or without devMode enabled.', LogLevel::Info, true);
  </code></pre>
  
  <p>Is this accurate?</p>
  
  <p>We've tried it. Doesn't seem to work as advertised. Nothing in the logs unless dev mode is turned on. And when it's turned on the Import plug-in hangs up. We're in a tough spot.</p>
  
  <p>What else should we be looking for? What else can we try?</p>
  
  <p>Craft CMS 2.6.2930 / Import 0.8.28 / PHP 5.6.10</p>
  
  <p><strong>EDIT:</strong><br>
  We have increased memory_limit 10 fold (1280M)<br>
  We have increased max_execution_time 100 fold (30000)<br>
  We have increased max_input_time 100 fold (60000)</p>
  
Tags: <plugin-development><import><logging>
Title: Why can't we log items regardless of dev mode?
ThreadText: # Why can't we log items regardless of dev mode?
  
  (Asked by: username_0 on 2016-09-13)
  
  Unfortunatley we need to develop an Import plug-in helper with dev mode OFF, for - according to username_1 at P&T:
  
  > devMode uses a lot more memory on a given PHP request and importing
  > probably already requires significant memory, so my guess is that
  > you're running into your php.ini file's memory\_limit or
  > max\_execution\_time limits or something similar.
  
  The Import plug-in is definitely a resource pig. We can't get it to work *at all* in dev mode. But we need to develop a plug-in using its hooks to help with things it can't handle in our situation (tables, dates, switches) so we're in a tough spot.
  
  According to [this](https://straightupcraft.com/articles/how-do-i-log-errors-warnings-and-info-in-my-plugins-to-a-craft-log-file) article:
  
  > If you want a log item to appear regardless of whether devMode is
  > enabled, you can pass true as the third argument to the log() method.
  
  ```
  SproutActivePlugin::log('Log this with or without devMode enabled.', LogLevel::Info, true);
  
  ```
  
  Is this accurate?
  
  We've tried it. Doesn't seem to work as advertised. Nothing in the logs unless dev mode is turned on. And when it's turned on the Import plug-in hangs up. We're in a tough spot.
  
  What else should we be looking for? What else can we try?
  
  Craft CMS 2.6.2930 / Import 0.8.28 / PHP 5.6.10
  
  **EDIT:**  
  We have increased memory\_limit 10 fold (1280M)  
  We have increased max\_execution\_time 100 fold (30000)  
  We have increased max\_input\_time 100 fold (60000)
  
  **Tags:** plugin-development, import, logging
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-13. Score: 2 | Accepted answer
  
  > If you want a log item to appear regardless of whether devMode is enabled, you can pass true as the third argument to the log() method.
  >
  > Is this accurate?
  
  Yes. Logs will only get flushed to disk is a proper `craft()->end()` occurs, firing the `onEndRequest` event. So if you're doing something in your plugin like calling PHP's `exit()` directly or there is some other logic that inadvertently kills the request, then they won't get written to the log file.
  
  I'd suspect that's what you're running into.
  
  > **Comments:**
  > **username_0**: Would the logs output fine with dev mode true? Because they do. I am trying to output logs from the Import `modifyImportRow` hook regardless of dev mode.  
  > **username_1**: And you're looking in `craft/storage/runtime/logs/sproutactive.log`?  I just tested this in a test plugin's init method with `TestPlugin::log('Log this with or without devMode enabled.', LogLevel::Info, true);` and devMode disabled and got the expected `2016/09/13 23:19:27 [info] [plugin] [Forced] Log this with or without devMode enabled.` in `test.log`.  
  > **username_0**: Yes, of course. If it ever gets written. But it doesn't. Something is screwy with the Import plug-in I think.  
  > **username_0**: I tried - as you - putting the line into the Import plug-in init method, and indeed works as expected. So something else is happening. Thanks for helping.  
  > **username_1**: Yeah, my guess is something in the plugin is improperly ending the request not giving Craft a chance to flush the logs. Still weird that it works fine with devMode on, though.  
  
  ---
  
  