<p>You should be able to do that with something like this:</p>

<pre><code>Craft::getLogger()-&gt;flush();
</code></pre>

CC BY-SA 3.0
2015-04-25T22:14:21.570Z
2015-04-25T22:14:21.570Z
Brad Bell
<p>Sometimes I have long running requests that do imports or similar. </p>

<p>Currently logging using <code>MyPlugin::log</code> is only actually written to file once the request is done. </p>

<p>Is there a way to trigger log-flushing mid-request?</p>

<plugin-development><logging>
Flushing logs halfway through a request?
# Flushing logs halfway through a request?

(Asked by: username_0 on 2015-04-25)

Sometimes I have long running requests that do imports or similar.

Currently logging using `MyPlugin::log` is only actually written to file once the request is done.

Is there a way to trigger log-flushing mid-request?

**Tags:** plugin-development, logging


---

## 1 answers

### Answer by username_1 on 2015-04-25. Score: 2 | Accepted answer

You should be able to do that with something like this:
Craft::getLogger()->flush();


---

