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.

·3 min read·View Oracle Docs

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.log to 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 LevelDescriptionExample Use
DebugLogs all messages. Ideal for testing, not for production scripts.log.debug
AuditRecords events during script processing. Useful for tracking actions.log.audit
ErrorOnly logs unexpected errors, helping in identifying issues.log.error
EmergencyLogs 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:

  1. Go to Customization > Scripting > Script Execution Logs.
  2. Use filtering options for log level, execution date range, and script names.
  3. 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 TypeNameReturn TypeSupported Script TypesDescription
Methodlog.audit(options)voidClient and server scriptsLogs an audit message.
Methodlog.debug(options)voidClient and server scriptsLogs a debug message.
Methodlog.emergency(options)voidClient and server scriptsLogs an emergency message.
Methodlog.error(options)voidClient and server scriptsLogs 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?
NetSuite allows up to 100,000 log object method calls within any 60-minute period across all scripts. If this limit is exceeded, the log level may automatically adjust.
What is the log retention period for the N/log module in NetSuite?
Logs older than 30 days are purged automatically from the system. Developers need to manage their logging data efficiently within this timeframe.
Are there limitations on logging messages in client scripts using the N/log module?
Yes, client scripts attached to forms using the N/log module will not log messages. Developers should use console.log for tracking client-side script execution details instead.
What is the database limit for the Script Execution Log page, and what can be done once it's exceeded?
The Script Execution Log page in NetSuite has a database limit of 5 million entries. If this limit is exceeded, you might need to leverage custom records for extended log storage.
Source: N/log Module Guidelines 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 General

View all General articles →