14 How Do I Search All Script Logs in NetSuite?

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.

Script Execution Logs Subtab

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.

Week View for Script Execution Log

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.

Server Script Log Search Type

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.

Script Execution Logs Page

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.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Related posts

January 7, 2021

Anything I wrote today about business would both feel and be inadequate. I simply can’t arrive at the words to express how I feel in this moment. So instead, here are a few helpful ...

Read More

December 20, 2020

2020 was a hundred swift kicks to the shorts and one giant kick in the ass. If you’ve lost people you love, if you’ve gotten sick or hurt, if you’ve lost your job, if ...

Read More

December 16, 2020

“I’ve been meaning to learn SuiteScript, but it’s hard to find the time …”“We’re slammed, and I just don’t have the time …”“I haven’t made the time …” All are variations of a theme ...

Read More

December 14, 2020

Last week we looked at mimicking the functionality of a REST endpoint with its own module (e.g. retrieving a User, or a list of Users, refreshing a token, etc). For complex integrations that rely on a large ...

Read More