<p>Just remove these two logging routes from your plugin's init() method in your PluginHandlePlugin.php file:</p>

<pre><code>craft()-&gt;log-&gt;removeRoute('WebLogRoute');
craft()-&gt;log-&gt;removeRoute('ProfileLogRoute');
</code></pre>

<p>That will prevent the extra logging and profiling information to be output in the browser's console when devMode is enabled.</p>

CC BY-SA 3.0
2014-06-26T01:23:51.370Z
Worked perfectly. Wouldn't you always want these removed when using methods like `returnJson`, or anything that explicitly returns non-html?
Tim Kelty
CC BY-SA 3.0
2014-06-26T06:59:45.223Z
Entirely possible, I suppose.
Brad Bell
CC BY-SA 3.0
2014-06-25T21:00:49.797Z
2014-06-25T21:06:23.190Z
2014-06-25T21:06:23.190Z
Brad Bell
<p>I have a plugin returning json from a controller action using <code>$this-&gt;returnJson(...)</code>.</p>

<p>Works great in production, but when <code>devMode = true</code>, the json is invalidated because Craft is still dumping the console debugging script at the end of the content.</p>

<p>What's the best way to avoid this?</p>

<plugin-development><json>
Console script tags garbling up non-html output (e.g. json) when in devMode
# Console script tags garbling up non-html output (e.g. json) when in devMode

(Asked by: username_0 on 2014-06-25)

I have a plugin returning json from a controller action using `$this->returnJson(...)`.

Works great in production, but when `devMode = true`, the json is invalidated because Craft is still dumping the console debugging script at the end of the content.

What's the best way to avoid this?

**Tags:** plugin-development, json


---

## 1 answers

### Answer by username_1 on 2014-06-25. Score: 8 | Accepted answer

Just remove these two logging routes from your plugin's init() method in your PluginHandlePlugin.php file:
craft()->log->removeRoute('WebLogRoute');
craft()->log->removeRoute('ProfileLogRoute');

That will prevent the extra logging and profiling information to be output in the browser's console when devMode is enabled.

> **Comments:**
> **username_0**: Worked perfectly. Wouldn't you always want these removed when using methods like `returnJson`, or anything that explicitly returns non-html?  
> **username_1**: Entirely possible, I suppose.  

---

