Created
May 14, 2017 13:15
-
-
Save mrister/eb773e183e7de6a2b348799ca64e89c7 to your computer and use it in GitHub Desktop.
Using MorganLogglyStream in express app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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