Skip to content

Instantly share code, notes, and snippets.

@geshan
Created March 10, 2021 22:07
Show Gist options
  • Save geshan/7d339480ab187fa5662bfa2e69d13525 to your computer and use it in GitHub Desktop.
Save geshan/7d339480ab187fa5662bfa2e69d13525 to your computer and use it in GitHub Desktop.
Markdium-5 Node.js Logging libraries compared for you to make the optimal choice
const express = require('express');
const app = express();
const port = 3002;
//more options here - https://github.com/villadora/express-bunyan-logger#usage
app.use(require('express-bunyan-logger')({
name: 'logger',
format: ":remote-address - :user-agent[major] custom logger",
streams: [{
level: 'info',
stream: process.stdout
}]
}));
app.get('/', (req, res) => {
res.send('Hello World! - Bunyan logged');
});
app.get('/api/test', (req, res) => {
res.json({'message': 'Hello bunyan!'});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment