N/log Module Guidelines for SuiteScript Logging Best Practices
The N/log module provides robust logging capabilities for SuiteScript, detailing usage guidelines, logging levels, and script execution insights.
The N/log module enables developers to manually log script execution details effectively. Proper usage of this module is essential for both debugging scripts and maintaining an efficient tracking process during execution.
Key Features of the N/log Module
- Logging Allowance: NetSuite allows up to 100,000 log object method calls in any 60-minute period across all scripts. If excessive logging is detected, the log level may be automatically adjusted.
- Log Retention Policy: Logs older than 30 days are purged automatically, making it crucial for developers to manage logging efficiently.
- Storage Limitations: The Script Execution Log page is subject to a database limit of 5 million entries. For extended log storage, you may need to leverage custom records.
- Execution Log Data: The Execution Log subtab will also display notes from NetSuite, including error messages, which can assist in debugging.
- Client Script Limitations: Client scripts attached to forms using the N/log module will not log messages. Instead, use
console.logto track client-side script execution details.
How to Use Log Levels
The logging methods paired with the Log Level field specified during script deployment allow control over which log messages are recorded:
| Log Level | Description | Example Use |
|---|---|---|
| Debug | Logs all messages. Ideal for testing, not for production scripts. | log.debug |
| Audit | Records events during script processing. Useful for tracking actions. | log.audit |
| Error | Only logs unexpected errors, helping in identifying issues. | log.error |
| Emergency | Logs critical errors that require immediate attention. | log.emergency |
Use these log levels judiciously to ensure performance and manage log volume effectively.
Viewing Script Execution Logs
To view execution logs:
- Go to Customization > Scripting > Script Execution Logs.
- Use filtering options for log level, execution date range, and script names.
- Download or print the logs as necessary.
When debugging with the SuiteScript Debugger, remember that messages will appear under the Execution Log subtab of the debugger itself rather than on the script deployment logs.
N/log Module Members
The N/log module consists of the following key methods:
| Member Type | Name | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
| Method | log.audit(options) | void | Client and server scripts | Logs an audit message. |
| Method | log.debug(options) | void | Client and server scripts | Logs a debug message. |
| Method | log.emergency(options) | void | Client and server scripts | Logs an emergency message. |
| Method | log.error(options) | void | Client and server scripts | Logs an error message. |
Note: In client scripts attached to forms, all logging functions like log.audit and log.debug will not record anything. Use console.log for those cases.
Conclusion
Effective use of the N/log module is pivotal in maintaining script performance and ensuring that developers can efficiently track and debug their scripts.
Frequently Asked Questions (4)
How many log object method calls are allowed in NetSuite within a specific timeframe?
What is the log retention period for the N/log module in NetSuite?
Are there limitations on logging messages in client scripts using the N/log module?
What is the database limit for the Script Execution Log page, and what can be done once it's exceeded?
Was this article helpful?
More in General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category