Testing server-side scripts
As with client-side scripting, there are a few ways to test server-side scripts. These are generally less immediate than the client-side debugging techniques, but essential when working to fix your code.
gs.log
The first logging technique we will look at is gs.log
. This was a very popular technique, and still is fairly widely used by developers. As we saw in Chapter 2, Exploring the ServiceNow Glide Class, gs.log
lets us send logs to the system log with a script source so we can send messages as a piece of code executes.
We can create a gs.log
from any server-side script, which makes it very useful; however, we cannot use it in a scoped application. We will have a look at scoped application logging later. As long as you are in the global scope, you can use gs.log
and send messages to the system logs.
Let's remind ourselves of a simple piece of code using a gs.log
:
gs.log('Server Side Log Message');
This log will appear in the Script Log Statements
module in the application...