finds.dev← search

// the find

expressjs/morgan

★ 8,181 · JavaScript · MIT · updated Jun 2026

HTTP request logger middleware for node.js

Morgan is HTTP request logging middleware for Express and vanilla Node.js servers. It handles the standard access log formats (Apache combined/common, plus dev-friendly colored output) and lets you define custom tokens. If you're running an Express app and need request logs, this is what you reach for.

The token system is genuinely well-designed — you can define custom tokens once globally and reference them by name in any format string, which keeps logging configuration DRY across a codebase. The `skip` function gives you a clean escape hatch for filtering noise (health checks, static assets) without forking the middleware. Dual-logger support works correctly because morgan can be mounted multiple times with different configs. The `immediate` flag solves a real problem: logging before the response means you still get a record even if the process crashes mid-request.

No structured/JSON logging out of the box — you have to build your own format function to get machine-readable output, which is what most production setups actually need. The response-time token measures time to headers-written, not body-flushed, which can mislead you on streaming responses. It writes synchronously to the stream by default, so under high load you're blocking the event loop on I/O unless you wire up your own buffered stream. The repo is effectively in maintenance mode — last meaningful feature was years ago, and there's no async-aware logging for async_hooks or request-scoped context propagation.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →