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

You Might Also Like
Our Free Plans just got better! | Auth0 by Okta Icon
Our Free Plans just got better! | Auth0 by Okta

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your secuirty. Auth0 now, thank yourself later.
Try free now
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