This week I’m responding to a troubleshooting comment from Effective SuiteScript reader, Michael Moen. Michael’s comment on the ESS mailing list was this:
I’ve seen references to being able to search through logs with SuiteScript. Being able to run global searches on logs would make my life a lot easier when it comes to troubleshooting.
NetSuite’s Script Execution Logs
Logging is probably the foremost debugging and troubleshooting tool we use as SuiteScript developers.
When you use NetSuite’s N/log
module to log messages from your Scripts, you are writing entries into the “Script Execution Log”. These entries are then displayed on the Execution Logs subtab of the corresponding Script or Script Deployment record that wrote the message.

By default, the view on this subtab will show you all log messages for the Script from today only.
If we would like a different View, perhaps a wider date range, we can do so by clicking Customize View. Perhaps we’d like a View that shows all of the logs for the last 7 days instead.

In this way, we can create multiple Views that we can easily switch between when viewing the logs for a particular Script.
Now what if we would like to see logs across multiple Scripts?
Script Execution Log Saved Searches
We can also create Saved Searches for Script Execution Logs. We do so by creating a new Saved Search with the Search Type Server Script Log.

From here, we can use all of our normal Saved Search capabilities to create the Execution Log results we want.
You can additionally create these same Execution Log Searches via SuiteScript by using the scriptexecutionlog Record Type.
Execution Log Limitations
These features can help us greatly in our troubleshooting efforts, but they have some significant limitations.
First, in order to pull up the correct Script record to view its logs, you would already need to know which Script is causing the problem. That is often not the case when we’re troubleshooting.
Second, these Script logs get purged regularly, automatically, and silently by NetSuite.
According to NetSuite Help:
Script execution logs are governed by a total storage limit on each instance of the NetSuite database. On each NetSuite server, if the database table that stores logs reaches this limit, all logs (across all customers on that server) are purged.
So, if NetSuite automatically purges your server’s log database the day after you receive that show-stopping error, then you’re completely out of luck.
NetSuite’s Separate Repository
To help alleviate some of these limitations, in 2016, NetSuite introduced a new Script Execution Logs page, which you can find under Customization > Scripting > Script Execution Logs.

This page lets us quickly filter and find Script Logs across all Scripts in our account.
The logs on this page are the same ones written by your Scripts, but NetSuite stores them in their own separate repository, which contains logs from your account only.
Messages in this separate repository are only purged after 30 days, so you can always look back to see all of your log messages for the past month across all of your Scripts.