Skip to content

Instantly share code, notes, and snippets.

@geshan
Created March 14, 2021 04:29
Show Gist options
  • Save geshan/b44288e6b26d7da53013010c6cf990f5 to your computer and use it in GitHub Desktop.
Save geshan/b44288e6b26d7da53013010c6cf990f5 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 pino = require('express-pino-logger')();
const port = 3003;
//more options here - https://github.com/pinojs/express-pino-logger#example
app.use(pino)
app.get('/', (req, res) => {
res.send('Hello World! - Pino logged');
});
app.get('/api/test', (req, res) => {
req.log.info('Yo from pino');
res.json({'message': 'Hello Pino!'});
});
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