This is a Node.js module available through the npm registry. Installation is done using the npm install command. Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name, a string of a format string, or a function that will produce a log entry. The format function will be called with three arguments tokens, req, and res, where tokens is an object with all defined tokens, req is the HTTP request and res is the HTTP response. The function is expected to return a string that will be the log line, or undefined / null to skip logging. Write log line on request instead of response. This means that a requests will be logged even if the server crashes, but data from the response (like the response code, content length, etc.) cannot be logged. To define a token, simply invoke morgan.token() with the name and a callback function.

Features

  • Use a predefined format string
  • Use a format string of predefined tokens
  • Use a custom format function
  • Output stream for writing log lines, defaults to process.stdout
  • There are various pre-defined formats provided
  • Concise output colored by response status for development use

Project Samples

Project Activity

See All Activity >

Categories

Logging

License

MIT License

Follow morgan

morgan Web Site

Other Useful Business Software
Gen AI apps are built with MongoDB Atlas Icon
Gen AI apps are built with MongoDB Atlas

The database for AI-powered applications.

MongoDB Atlas is the developer-friendly database used to build, scale, and run gen AI and LLM-powered apps—without needing a separate vector database. Atlas offers built-in vector search, global availability across 115+ regions, and flexible document modeling. Start building AI apps faster, all in one place.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of morgan!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Logging Software

Registered

2021-08-23