@elastic/ecs-morgan-format
A formatter for the morgan logger compatible with Elastic Common Schema.
In combination with filebeat you can send your logs directly to Elasticsearch and leverage Kibana's Logs UI to inspect all logs in one single place.
Install
npm i @elastic/ecs-morgan-format
Usage
const app = require('express')()
const morgan = require('morgan')
const ecsFormat = require('@elastic/ecs-morgan-format')()
app.use(morgan(ecsFormat))
app.get('/', function (req, res) {
res.send('hello, world!')
})
app.listen(3000, () => {
console.log('Listening')
})
Options
You can pass any format option you would normally pass to morgan
, and the log message will use the specified format (the default is combined
).
const app = require('express')()
const morgan = require('morgan')
const ecsFormat = require('@elastic/ecs-morgan-format')('tiny')
app.use(morgan(ecsFormat))
License
This software is licensed under the Apache 2 license.