README
This is a simple lib to log message
Latest release
1.0.4 (2021-05-11)
Other
- deps: update bunyan to 1.8.15 (fda08f1)
- deps: update CBuffer to 2.2.0 (9dd31d7)
- deps: update config to 3.3.6 (d98a777)
- deps: update gelf-pro to 1.3.5 (5ee7c64)
- deps-dev: update devDependencies to latest versions (0c141ed)
Installation
npm install s3pweb-logger
Config
Configurations are stored in configuration files within your application, and can be overridden and extended by environment variables, command line parameters, or external sources. See : http://lorenwest.github.io/node-config/
Create a config folder
Create a file(s) with the name of your environment(s) like test.json
Paste this configuration template :
{
"name": "your-application-name",
"logger": {
"source": false,
"console": {
"enable": true,
"level": "debug"
},
"file": {
"enable": true,
"level": "info",
"dir": "./logs"
},
"server": {
"enable": true,
"level": "trace",
"url": "0.0.0.0",
"port": "9998",
"type": "elk"
},
"ringBuffer": {
"enable": true,
"size": 50
}
}
}
- Adapt values with your expectations
Example :
const log = require('@s3pweb/s3pweb-logger').logger
const { logger } = require('@s3pweb/s3pweb-logger')
const child = log.child({ child: 'childName' })
log.info('one message from log')
logger.info('one message from logger')
child.info('one message from child')
Run example :
Pass the name of your environnement with NODE_ENV=xxxx before node
NODE_ENV=test node example/example.js
Bonus :
To start a ELK stack on docker :
chmod +x example/startElk.sh
./example/startElk.sh
Or with docker compose :
docker-compose -f example/docker-stack.yaml up -d
Open your favorite browser : http://localhost:5601
Create an index with just * (replace logstash-* by *)