# Is there a console to debug server side scripts?

**URL:** <https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429>\
**Category:** Server-Side Scripting\
**Created:** [October 6, 2014, 8:09am UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429 "2014-10-06T08:09:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![meinbrodt](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@meinbrodt](https://community.dreamfactory.com/u/meinbrodt)\
**Post date:** [October 6, 2014, 8:09am UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/1 "2014-10-06T08:09:23Z")

</div>

Hello,

I was just playing a round a little bit with the server side scripting capabilities of DSP.

Having done some frontend Javascript Development I’m relying on the browser console a lot of times in order to quickly debug/test my code (e.g. showing the result of modifications to an object etc.).

Since the JS interpretation and execution takes place on the server. I was wondering if there exists a way to patch eventual output of the V8 engine through to my browser console or if there is such a thing as a server-side console available.

Best regards, Matthias

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [October 6, 2014, 9:51pm UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/2 "2014-10-06T21:51:18Z")

</div>

There’s a blog post that shows how to write to your DSP’s log file [https://blog.dreamfactory.com/build-your-own-web-services-using-dreamfactory-custom-scripts](https://blog.dreamfactory.com/build-your-own-web-services-using-dreamfactory-custom-scripts)

You can also have the script return data back to the client in JSON format.

result.debugInfo = “whatever”;  
return result;

Or you can have the script throw an exception, which can pass data back to the client.

From the blog post…

Scripts can also write to the DSP’s log file which is useful for debugging. The PHP functions print, print\_r, and var\_dump are available to be called from the Javascript engine. By default the output of these will go to the log file in your DSP’s /log directory. On a Bitnami OS X installation that directory would be something like

/Applications/dreamfactory-1.7.8-0/apps/dreamfactory/htdocs/log

Adding the following line to the script would write to your log file. Please use logging sparingly as it does negatively affect script performance.

```
print(event.n1 + " + " + event.n2 + " = " + result);

```

The output would look like this.

```
[2014-09-03 16:37:53] app.INFO: Script User Script "add" output:
4 + 2 = 6
 [] []
```

---

<div class="post-metadata">

**Author:** ![meinbrodt](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@meinbrodt](https://community.dreamfactory.com/u/meinbrodt)\
**Post date:** [October 7, 2014, 10:14am UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/3 "2014-10-07T10:14:32Z")

</div>

Hello Ben,

thanks for that information. I haven’t seen that blog post.

Regards, Matthias

---

<div class="post-metadata">

**Author:** ![Krishna\_G](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@Krishna\_G](https://community.dreamfactory.com/u/Krishna_G)\
**Post date:** [March 15, 2016, 6:54pm UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/4 "2016-03-15T18:54:32Z")

</div>

Hi Ben,

I might be asking a followup question on this very lately. Sorry for that.  
Even though I use print statement, nothing is being displayed in the log. Is there any setting we should do?

Please suggest.

Thanks  
Krishna

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [March 15, 2016, 8:06pm UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/5 "2016-03-15T20:06:18Z")

</div>

try var\_dump, like this for example:

`var result = platform.api.get("mongodb/_table/contact", params); var_dump("dumping result"); var_dump(result);`

---

<div class="post-metadata">

**Author:** ![Krishna\_G](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@Krishna\_G](https://community.dreamfactory.com/u/Krishna_G)\
**Post date:** [March 16, 2016, 3:51am UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/6 "2016-03-16T03:51:13Z")

</div>

Hi Ben,

Thank you for the suggestion. I used var\_dump as well. The log is not capturing any of these messages. I am always getting the message as follows in the log:

> [2016-03-16 03:43:09] local.DEBUG: Resource event: srdb.table.FirstTable.post.postprocess  
> Even  
> adding var\_dump(“Starting”) step in the post or pre process of processing event, none of these messages are being displayed.

Please suggest.I a trying to do this since for 1 week.

Best Regards  
Krishna G

---

<div class="post-metadata">

**Author:** ![Vsevolod\_Gromov](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/vsevolod_gromov/32/841_2.png) [@Vsevolod\_Gromov](https://community.dreamfactory.com/u/Vsevolod_Gromov)\
**Post date:** [July 27, 2016, 6:30pm UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/7 "2016-07-27T18:30:39Z")

</div>

The following is working OK from PHP script code:  
`error_log( print_r( $var_to_dump, true ) );`

---

<div class="post-metadata">

**Author:** ![formerstaff](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/formerstaff/32/1133_2.png) [@formerstaff](https://community.dreamfactory.com/u/formerstaff)\
**Post date:** [July 29, 2016, 2:47pm UTC](https://community.dreamfactory.com/t/is-there-a-console-to-debug-server-side-scripts/429/8 "2016-07-29T14:47:18Z")

</div>

You will need to have debug logging turned on in order for dumping from scripts to work.

[https://wiki.dreamfactory.com/DreamFactory/Troubleshooting](https://wiki.dreamfactory.com/DreamFactory/Troubleshooting)
