Logging Events to Loggly

While you can create flows that log events in any way that works best for you, Verizon Connect® Flows™ makes it easy to send this data directly to Loggly. Using Loggly, you can manage your logs from a central location where you have access to robust search functionality and where you can set up notifications about any issues that matter the most to you. Loggly also provides dashboards that help you to view the log activity across your account and view any issues that have triggered alerts.

You must have a Loggly account to use the functionality described in this topic.

Enabling Logging in a Flow

Before you use any logging nodes or functions in a flow, first you must set up the flow’s logging settings.

1.From the Developer Console, select the "Edit settings" option from the drop-down menu to the right of the flow that you want to enable logging for.
2.For each of the following options, select the Override check box, then edit the following entries:
loggly_loglevel: Select the logging level cutoff point for the flow. Flow messages are only sent to Loggly if the log level of the message is the same or less than the level selected for this setting. See the Log levels section for more information.
loggly_subdomain: Enter your Loggly Account Name. For example, if your Loggly URL is http://MyAccount.loggly.com, enter MyAccount.
loggly_token: Enter the Customer Token supplied by Loggly for your account.
3.Click Save.

Log Levels

The purpose of the log level settings is to select a cutoff point for the messages that are logged. There are eight log levels, listed below in order of severity:
 

0 - Emergency
1 - Alert
2 - Critical
3 - Error
4 - Warning
5 - Notice
6 - Info
7 - Debug

When you select a log level, logging is enabled for the selected level and below. For example, if you select Warning, log messages are only sent to Loggly for logging events that are marked as Warning, Error, Critical, Alert, or Emergency. All other messages are ignored and not logged in Loggly.

When selecting a log level, we recommend the following:
 

Only use the Debug and Info log levels to help during development, when you may need additional information. Note that with these settings, some system messages may be displayed in the logs.
When a flow is ready for use in production, change the log level to Notice or lower.

Setting log levels

The loggly_loglevel you select for the flow from the Edit settings dialog box applies to the entire flow. The severity levels set in the logging or function nodes described below only apply to the individual message being logged and do not override the log level settings selected for the full flow. For example, if you set the flow’s loggly_loglevel to Warning but configure a logging node with a Severity of Notice, then no messages are logged for that node.
 

Logging node: When editing the logging node, the option you select from the Severity drop-down menu determines the log level applied to that node.
Log function in a function node: You can also add log functions to the function node and set log levels for each log function you add.

If log messages are not displayed in Loggly as expected, check each of the locations above to determine if the cause of the problem is the log level configured for the message.

Using Loggly in Flows

Once you have enabled logging in your flow, you can add logging using either method below:
 

Add a logging node
Add a Log function to a function node

Adding a logging node

To send log events to Loggly, you can add one or more logging nodes to your flow.
 

1.From the Advanced section in the Flow Editor, drag the logging node onto your workspace.
2.Double-click the logging node to configure the following options:
Name: Enter the name of the logging node, if you want it to be different than the default name (logging).
Severity: Select the logging level for the message. Messages are only sent to Loggly if the log level of the message is the same or less than the level selected for this setting. For more information, see the Log levels section.
Message: Enter the message to be written to the log. It uses Mustache formatting, so that data can easily be extracted from the incoming msg object.
 
For example, if the incoming msg object contains a property named payload that contains an array of 6 items, then you can use the .length JavaScript method to count the number of items in the array. When the message Started processing {{{payload.length}}} records is logged, the resulting message to Loggly is: Started processing 6 records
 
Tags: Enter any tags you want to apply to your message when it is sent to Loggly. Tags help you to segment and filter your log events, so that they are easier to search in Loggly. Tags can be a single word or multiple words. Separate multiple tags with a comma. For example, devTesting, Monday, new sql statement
Send Object msg: When this option is selected, in addition to sending the message to Loggly, the message is also passed along in the flow in the msg object within the property field specified (default is payload). When this option is not selected, the message is only sent to Loggly.
 
3.Click OK to save your changes.

Logging in a function node

Logging functionality can also be added within a function node in your flow using the log function.

You can use any of the three log functions described below to log messages to Loggly.

Log function

Example

Notes

log.log(logLevel, message, data, tags)

log.log(0, ‘Emergency message to send’)

The first parameter sets the Log level for the message numerically.

log.log(‘logLevel’, message, data, tags)

log.log(‘emergency’, ‘Emergency message to send’)

The first parameter sets the Log level for the message as a string.

log.logLevel(message, tags, data)

log.emergency(‘Emergency message to send’)

The logLevel method sets the Log level for the message.

Each log function contains the following elements:
 

logLevel: (required) Specifies the log level of the message. See the Log Level section for the full list of levels and the corresponding numerical values. For each function described in the table above, the logLevel must be provided in the position indicated.
message: (required) The message to be written to the log.
data: (optional) The data object to be logged. For example, {‘test01’: 'good'}. Note that all parameters in the data object must be stringified, otherwise Loggly interprets the parameters as tags and not as individual pieces of data.
tags: (optional) Any tags that should be sent to Loggly for search purposes. This value must be an array of one or more strings. For example ['ftp import’] or ['adding gps data', 'merge conflict'].

The data and tags parameters can be provided in any order.

Other messages sent to Loggly from the function node

The following messages can also be sent to Loggly, depending on the Log Level you have selected for the flow:
 

node.error(), throw new error() generates logs with a log level of Error.
console.log() generates logs with a log level of Debug.
node.log() generates logs with a log level of Info.

The three methods above do not support the use of tags.

The node.warn() method does not generate a log.