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 Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category