# Toggle Debugging? Looking for suggestions

**URL:** <https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634>\
**Category:** Help Hub\
**Created:** [January 8, 2018, 6:09pm UTC](https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634 "2018-01-08T18:09:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmccann](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/tmccann/32/3550_2.png) [@tmccann](https://community.postman.com/u/tmccann)\
**Post date:** [January 8, 2018, 6:09pm UTC](https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634/1 "2018-01-08T18:09:26Z")

</div>

Hey all,

The more and more I work with Postman I find myself creating lots of collections that can get quite elaborate.

One thing I find myself doing often is using the console.log statement to output values or in some cases request/response bodies.

Most of the time I dont want these log statements in general as we do a lot of automated runs via Jenkins and this is just unnecessary output in the logs.

Does anyone have a preferred way of adding in debugging in their calls?  
I was thinking along the lines of adding in some toggle that I would enable at the start of my collection to tell it to output the console logs or not, however the refactor effort would be quite great if I were to do this.

Just looking to see if others have done something similar

Thx,Trent

---

<div class="post-metadata">

**Author:** ![dhoyt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/dhoyt/32/238_2.png) [@dhoyt](https://community.postman.com/u/dhoyt)\
**Post date:** [January 9, 2018, 6:45pm UTC](https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634/2 "2018-01-09T18:45:16Z")

</div>

Any solution that you may implement at this point would require a refactor to any of your collections that you would want to apply the solution to … no getting around it.

I haven’t had the need to implement this but you could set global variables to “true” or “false” for the level of console output you would require …

```auto
pm.globals.set("debug", false);
pm.globals.set("info", false);
pm.globals.set("trace", false);

```

I would set them in the globals.postman\_globals.json instead so that I would be sure that the variables would always be set and ready for any and all my collections.

And in your POSTMAN javaScripts, you could have …

```auto
if ( pm.globals.get("debug") )
    console.log("This is a debug msg");
if ( pm.globals.get("info") ) 
    console.log("This is an info msg");
if ( pm.globals.get("trace") ) 
    console.log("This is a trace msg");

```

or combinations of the settings …

```auto
if ( pm.globals.get("info") || pm.globals.get("trace") ) 
    console.log("This is a msg that I really want to see ");

```

Hope this help.

---

<div class="post-metadata">

**Author:** ![tmccann](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/tmccann/32/3550_2.png) [@tmccann](https://community.postman.com/u/tmccann)\
**Post date:** [January 9, 2018, 7:00pm UTC](https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634/3 "2018-01-09T19:00:03Z")

</div>

@dhoyt This is great, its kind of along the lines of what I was thinking but I do like your usage of the global variables.

thanks for the feedback.

~ trent

---

<div class="post-metadata">

**Author:** ![dhoyt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/dhoyt/32/238_2.png) [@dhoyt](https://community.postman.com/u/dhoyt)\
**Post date:** [January 9, 2018, 7:02pm UTC](https://community.postman.com/t/toggle-debugging-looking-for-suggestions/634/4 "2018-01-09T19:02:41Z")

</div>

Glad to have helped !
