Unlocking NetSuite logging

Many organizations miss out on using NetSuite logging to its full potential.

For debug level lines, most organizations use them for outputing variables similar to how we used to log variables out before we had debuggers. Audit level lines are used for significant events or actions without any context.

While this might work for trivial solutions, it does not scale for large complex solutions.

For enterprise solutions, logging is crucial for debugging and monitoring. We need to be able to see patterns in order to solve complex and edge case issues.

Constraints in NetSuite Logging

NetSuite has limitations on logging:

  1. Retention: Logs are retained for up to 30 days, but high log volume can result in significantly shorter retention periods. While the Script Execution Logs under Customization > Scripting are retained for the full 30 days, other log sources may not be.
  2. Log Count Limits: NetSuite caps log method calls at 100,000 per hour. Exceeding this threshold prompts Oracle to raise the script's log level, often reducing debug-level logs to audit and potentially then further to just errors, diminishing the value of the logs.

To address these constraints, it's critical to approach logging with a strategy tailored for large-scale, complex solutions.

Optimizing NetSuite Logging for Enterprise Use

  1. Efficient Use of Log Fields: Minimize log calls by utilizing both the title and description fields effectively. For example, consolidate multiple variable values into one line, the simplest being single JSON object, rather than creating separate log lines.
  2. Add Context to Log Lines: Instead of using separate lines for additional information, include context like record IDs and execution times in the same log line. For instance, by including a record ID directly within a log line, you'll have immediate context for events or errors without needing to reference other logs.
  3. In BeforeSubmit events there is not yet a record id yet since the record is not yet saved.  However, there is still an opportunity to indicate the record.  For example, with Sales Orders, I have created a simple script that depending on our type of Sales Order, I grab the corresponding id for that type and use that to build the record identifier that is then prepended onto every log line moving forward.
  4. Track Performance Metrics: Include execution times for actions or steps in your log lines. This helps you monitor script performance over time and identify potential bottlenecks.
  5. Stay Informed: Create a saved search to email all error, emergency, and system-level log lines. This keeps you proactively informed about critical issues in your system.

By refining your logging practices and addressing NetSuite's limitations, you can unlock a new level of insight and reliability in your solution. For additional details on NetSuite's logging governance, visit Oracle's documentation.