N/log Module
Use the N/log module to manually access methods for logging script execution details. These methods can also be accessed using the global log object. For more information about the global log object, see log Object.
Log messages appear on the Execution Log tab of the script deployment for deployed scripts, or on the Execution Log tab of the SuiteScript Debugger if you are debugging a script. Log messages also appear on the Script Execution Logs page at Customization > Scripting > Script Execution Logs.
In This Help Topic
N/log Module Guidelines
The following guidelines are provided for use of the N/log module:
-
NetSuite governs the amount of logging that can be done in any specific 60 minute time period. A company is allowed to make up to 100,000 log object method calls across all of their scripts. Script owners are notified if NetSuite detects that one script is logging excessively and automatically adjusts the log level.
-
NetSuite purges logs older than 30 days.
-
The Server Script Log search and the Execution Log tab of script records and script deployment records have a log storage limit of 5 million per database. Because log persistence is not guaranteed, You should use custom records if you want to store script execution logs for extended periods. The Script Execution Logs page at Customization > Scripting > Script Execution Logs does not share the same database limit.
-
The Execution Log tab also lists notes returned by NetSuite such as error messages. For more information, see N/error Module.
-
If you deploy a client script to a form using Form.clientScriptFileId or Form.clientScriptModulePath, using the N/log module adds the logs to the deployment of the parent script. The parent script can be either a
beforeLoad
user event script or a SuiteScript 2.x Suitelet Script Type. -
When an object (that is not a string) is passed to a log object method, NetSuite runs JSON.stringify(obj) on any values that are passed as the
details
parameter and equal a JavaScript object.... // log.debug(myRecord) //Shows the JSON representation of the current values in the myRecord object var id = myRecord.save(); ...
Using Log Levels
Use the log methods along with the Log Level field on the script deployment to specify which log messages are written to the Execution Log on the script deployment. This is useful during the debugging of a script or for providing useful execution notes for auditing or tracking purposes.
Log levels on the script deployment and N/log module methods act as a filter on the amount of information logged. The following Log Levels are supported:
Log Level |
Example Uses |
---|---|
Debug |
Use Debug to show all messages. This type of logging is suitable only for testing scripts. To avoid excessive logging, don't use Debug level for active scripts in production. |
Audit |
Use Audit to shows a record of events that have occurred during the processing of the script (for example, “A request was made to an external site.”). |
Error |
Use Error to show only unexpected script errors. |
Emergency |
Use Emergency to show only the most critical errors in the script log. |
The following table shows you which type of log messages are written based on the Log Level field selected on the script deployment and the log method used in your script.
Log Level |
Log method used in your script |
|||
---|---|---|---|---|
|
||||
Emergency |
|
— |
— |
— |
Error |
|
|
— |
— |
Audit |
|
|
|
— |
Debug |
|
|
|
|
Viewing Script Execution Logs
Log messages for a specific script are shown on the Execution Log of the script deployment for the script. These logs are not guaranteed to persist for 30 days and may be purged to enhance performance if volume is high.
To view script execution log details for various scripts, go to Customization > Scripting > Script Execution Logs. This list of script execution logs is an enhanced repository that stores all log details for 30 days.
On this page, you can perform the following tasks:
-
Search for specific logs using filter options, such as log level, execution date range, and script name.
-
Download the list as a CSV file or an Excel spreadsheet.
-
Print the list.
When you debug a script in the SuiteScript Debugger, log messages appear on the Execution Log tab of the SuiteScript Debugger and do not appear on any Execution Tab of any script deployment.
N/log Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
void |
Client and server scripts |
Logs an Audit message. |
|
void |
Client and server scripts |
Logs a Debug message. |
||
void |
Client and server scripts |
Logs an Emergency message. |
||
void |
Client and server scripts |
Logs an Error message. |