log Object Members and Methods in SuiteScript 2.x
The log object in SuiteScript 2.x facilitates detailed logging for script execution, ensuring better debugging and monitoring.
The log object in SuiteScript 2.x is automatically loaded for all script types, providing essential logging methods without requiring manual loading. This functionality is crucial for developers looking to monitor script execution and troubleshoot issues effectively.
Overview of the log Object
NetSuite's log object includes several methods that allow developers to log different levels of messages. By utilizing these methods, developers can track the flow of execution and gather information about potential errors or issues.
Available Methods of the log Object
| Method Name | Description |
|---|---|
log.debug(options) | Logs debug-level messages useful during development. |
log.audit(options) | Logs audit-level information for monitoring important events. |
log.emergency(options) | Logs emergency messages for critical issues that need immediate attention. |
log.error(options) | Logs error messages detailing issues that arise during execution. |
Key Points to Consider
- Variable Naming Conflicts: When using SuiteScript 1.0 scripts alongside SuiteScript 2.0, be cautious of naming variables as
logorutil, as these are reserved keywords in SuiteScript 2.x. Updating variable names in SuiteScript 1.0 is necessary to avoid errors. - Logging Limits: NetSuite imposes limits on logging to promote efficient use of resources. Developers can make a maximum of 100,000 log calls across all scripts in a 60-minute period. If one script logs excessively, the system will adjust the log level automatically.
- Log Retention: System logs older than 30 days are purged automatically. For longer retention, consider using custom records.
Accessing Log Messages
Log messages generated by the log object can be viewed in several places within the NetSuite interface:
- Execution Log subtab in the script deployment record
- SuiteScript Debugger when scripts are being debugged
- Script Execution Logs available at Customization > Scripting > Script Execution Logs
For more comprehensive logging capabilities, use the N/log module which offers additional functionality to access and utilize log methods dynamically.
Conclusion
Incorporating the log object within your SuiteScript 2.x scripts will enhance your development workflow by providing essential debugging and logging capabilities. Understanding how to effectively use this object is crucial for maintaining efficient and error-free script execution.
Frequently Asked Questions (4)
Do I need to manually load the log object in SuiteScript 2.x?
What are the logging limits for the log object in NetSuite?
Where can I view log messages generated by the log object?
What should I be cautious of when using SuiteScript 1.0 scripts with SuiteScript 2.0?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
