Logentries Docs

Find comprehensive guides and documentation to help you start and continue to work with Logentries.

    
discard

Search results for "{{ search.query }}"

No results found for "{{search.query}}".

node.js

Logentries supports Logging using node.js.

Setup

Log in to Logentries and create a new log by clicking the Add New Log button. Now click Manual Configuration button from the list of options. Give your log a name of your choice, select Token TCP and finally click the Register new log button. A token will be displayed in green. Please record it as we will use it later to configure the library.

Install Logentries library

Run the following command to install node.js library:

npm install le_node --save

Configure your code

var Logger = require('le_node');
var logger = new Logger({
  token:'LOGENTRIES_TOKEN'
});

The LOGENTRIES_TOKEN parameter needs to be replaced with the token for the log we created earlier. There are many other options available when instantiating the Logger, which you can read about on the GitHub project page.

Insert Logging Code

The module provides you with a set of logging methods that correspond to the standard syslog log levels. These are, in order of increasing severity: debug, info, notice, warning, err,`` crit,alert,emerg```.

// level specific methods like 'info', 'debug', etc.
log.info("I'm a Lumberjack and I'm OK")

// generic log method, also accepts JSON entries
log.log("debug", {sleep:"all night", work:"all day"})

node.js