Skip to content

Morgan#

HTTP request logger middleware for Node.js.

Why Morgan?#

  • ✅ Simple and lightweight
  • ✅ Multiple logging formats
  • ✅ Custom format support
  • ✅ Works with Express, Koa, etc.
  • ✅ Production-ready

Quick Start#

npm install morgan
const express = require('express')
const morgan = require('morgan')

const app = express()

// Use predefined format
app.use(morgan('combined'))

app.listen(3000)

Log Output Example#

::1 - - [26/Nov/2025:15:30:15 +0000] "GET /api/users HTTP/1.1" 200 1234

Common Formats#

  • combined - Standard Apache combined log
  • common - Standard Apache common log
  • dev - Color-coded by response status (for development)
  • short - Shorter than default
  • tiny - Minimal output

Resources#