Purpose
Logdunum is made in order to make logging in a cluster of several servers a breeze, using MongoDB to store everything fast. This part provides an API for logging from your NodeJS code, you are advised to install the cli in global in order to show and filter your logs.
Install
- add the logdunum lib to your project :
#add logdunum to your project $> npm install --save logdunum
- add the logdunum CLI to your system in global :
#install the cli $> sudo npm install -g ldm
Usage
- in your code, in order to log something :
var logger = module // you should get it locally in each module to report the file loggerloggerlogger
- in your console, using the ldm CLI :
$> ldm -f -n 50
You can get help with the cli using --help :
$> ldm --help Usage: ldm [options] Options: -h, --help output usage information -V, --version output the version number -n, --lines [number] only output the last n lines -f, --follow output appended lines as their arrive -l, --level [level] filter lines by level, either as a regexp, or a comma separated list -m, --min [level] minimal level threshold, [trace < debug < log < info < warn < error < fatal] -u, --user [user] output only what happened
Configuration
You can configure logdunum with everything available in lib/config.js
thanks to cfg, so you can override settings thank to the process arguments using namespace 'logdunum' or by prefixing environnment variable with 'LOGDUNUM'. It works both with your own program using logdunum and with the ldm CLI :
- examples :
$> ./myprogram --logdunum-database mylogs$> ldm --logdunum-collection logdunumLogs$> LOGDUNUM_PORT=27018 ldm -f