NodeJS
InsightOps supports logging using node.js.
Setup
Log in to InsightOps and create a new log by clicking the Add Data button in the Data Collection page. Now click the Quick Add 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:
1npm install r7insight_node
Configure your code
javascript
1var Logger = require('r7insight_node');23var logger = new Logger({ token: 'logToken' , region: 'myRegion'});45logger.warning('The kittens have become alarmingly adorable.')
The Log Token parameter needs to be replaced with the token for the log we created earlier. We then need to enter in the Region which our InsightOps account is based e.g us, eu, apac.
There are many other options available when instantiating the Logger, which you can read about on the 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```.
javascript
1// level specific methods like 'info', 'debug', etc.2logger.info("I'm a Lumberjack and I'm OK")34// generic log method, also accepts JSON entries5logger.log("debug", {sleep:"all night", work:"all day"})