N/log Module

Use the N/log module to manually access methods for logging script execution details. These methods can also be accessed using the global log object. For more information about the global log object, see log Object.

Log messages appear on the Execution Log tab of the script deployment for deployed scripts, or on the Execution Log tab of the SuiteScript Debugger if you are debugging a script. Log messages also appear on the Script Execution Logs page at Customization > Scripting > Script Execution Logs.

                                   

In This Help Topic

N/log Module Guidelines

The following guidelines are provided for use of the N/log module:

Using Log Levels

Use the log methods along with the Log Level field on the script deployment to specify which log messages are written to the Execution Log on the script deployment. This is useful during the debugging of a script or for providing useful execution notes for auditing or tracking purposes.

Log levels on the script deployment and N/log module methods act as a filter on the amount of information logged. The following Log Levels are supported:

Log Level

Example Uses

Debug

Use Debug to show all messages.

This type of logging is suitable only for testing scripts. To avoid excessive logging, don't use Debug level for active scripts in production.

Audit

Use Audit to shows a record of events that have occurred during the processing of the script (for example, “A request was made to an external site.”).

Error

Use Error to show only unexpected script errors.

Emergency

Use Emergency to show only the most critical errors in the script log.

The following table shows you which type of log messages are written based on the Log Level field selected on the script deployment and the log method used in your script.

Log Level

Log method used in your script

 

log.emergency(options)

log.error(options)

log.audit(options)

log.debug(options)

Emergency

checkmark

Error

checkmark

checkmark

Audit

checkmark

checkmark

checkmark

Debug

checkmark

checkmark

checkmark

checkmark

Viewing Script Execution Logs

Log messages for a specific script are shown on the Execution Log of the script deployment for the script. These logs are not guaranteed to persist for 30 days and may be purged to enhance performance if volume is high.

To view script execution log details for various scripts, go to Customization > Scripting > Script Execution Logs. This list of script execution logs is an enhanced repository that stores all log details for 30 days.

On this page, you can perform the following tasks:

When you debug a script in the SuiteScript Debugger, log messages appear on the Execution Log tab of the SuiteScript Debugger and do not appear on any Execution Tab of any script deployment.

N/log Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

log.audit(options)

void

Client and server scripts

Logs an Audit message.

log.debug(options)

void

Client and server scripts

Logs a Debug message.

log.emergency(options)

void

Client and server scripts

Logs an Emergency message.

log.error(options)

void

Client and server scripts

Logs an Error message.

Related Topics

General Notices