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.

·2 min read·View Oracle Docs

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 NameDescription
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 log or util, 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?
No, the log object is automatically loaded for all script types in SuiteScript 2.x, so manual loading is not required.
What are the logging limits for the log object in NetSuite?
NetSuite enforces a limit where developers can make a maximum of 100,000 log calls across all scripts in a 60-minute period. If a script logs excessively, the system will adjust the log level automatically.
Where can I view log messages generated by the log object?
Log messages can be viewed in the Execution Log subtab in the script deployment record, the SuiteScript Debugger when debugging scripts, and under Customization > Scripting > Script Execution Logs.
What should I be cautious of when using SuiteScript 1.0 scripts with SuiteScript 2.0?
You should avoid naming variables as 'log' or 'util' in SuiteScript 1.0, as these are reserved keywords in SuiteScript 2.x. Updating variable names in SuiteScript 1.0 scripts is necessary to avoid errors.
Source: log Object Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →