3

For example the template just outputs JSON, which breaks when Craft's devMode logging is added.

  • 1
    I'm not aware of any way to disable the debugging output from the template, but if you use the header tag to explicitly set the document's content type to JSON, Craft wont output the debug data: {% header "Content-Type: application/json" %} – Mats Mikkel Rummelhoff Mar 5 '15 at 16:16
  • Thanks Mats - worked fine. Do you want to create an answer so I can mark it as accepted? – Russ Back Mar 6 '15 at 12:15
  • That's great – I added an answer, thanks for following up. – Mats Mikkel Rummelhoff Mar 6 '15 at 12:28
4

You can't disable the debugging output using Twig/templates.

However, Craft will only render the debug data if your document' Content-type header is either "text/html" or "application/xhtml+xml" (source).

This means that if you're outputting JSON, you can set the template's Content-type to "application/json" (using Craft's header tag), preventing Craft from dumping the debug data to the response:

{% header "Content-Type: application/json" %}
| improve this answer | |
7

You can create a simple plugin with an init() method like so:

public function init()
{
    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.

| improve this answer | |
  • Thanks Brad - good to know. Setting the Content-Type was enough in the end, at least for this particular scenario. – Russ Back Mar 6 '15 at 12:15
  • I putt this on github if people are feeling lazy: github.com/crswll/silence – Bill Criswell Mar 21 '15 at 1:29

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.