Skip to content

Instantly share code, notes, and snippets.

@mrister
Created May 14, 2017 13:15
Show Gist options
  • Save mrister/eb773e183e7de6a2b348799ca64e89c7 to your computer and use it in GitHub Desktop.
Save mrister/eb773e183e7de6a2b348799ca64e89c7 to your computer and use it in GitHub Desktop.
Using MorganLogglyStream in express app
const express = require('express');
const morgan = require('morgan');
const MorganLogglyLoggerStream = require('./morgan-loggly');
const app = express();
const logglyStream = new MorganLogglyLoggerStream(
{
TOKEN: 'YOUR TOKEN',
SUBDOMAIN: 'YOUR SUBDOMAIN'
}
);
// setup the logger
app.use(morgan('combined', {stream: logglyStream}));
app.get('/', (req, res) => {
res.send('Hello from Express.js server!')
});
// run the server
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Example app listening on port ${PORT}!`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment