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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category