Learn how to use Morgan, a Node.js Express middleware logger to log request paths, status codes, duration, and more.
- [Instructor] It's good to avoid reinventing the wheel,…and we made a pretty square one a couple of videos ago…when we used the console to log requests.…As we saw, it worked, but it wasn't optimal.…Is there a better solution?…Yes, and it's called morgan.…Morgan is a no-JS HTTP request logger middleware…which supports servers including Express.…When logging, morgan includes a number of details…about the HTTP method, path requested, and content length.…
Morgan logs once the request is sent…so it can include the HTTP status code and response time,…which is really useful for debugging…and finding slow performance.…Optionally, morgan can also include the referrer…and user agent strain.…Morgan can be used with most loggers, including Winston.…Morgan provides some very convenient logging format defaults…including the standard Apache combined log output.…It also provides a system of token replacements…so you can easily create your own, or customize it.…
We're going to replace our console logger with morgan.…Switch over to VS Code.…
- Building a troubleshooting mindset
- Why measure performance?
- What's a microservice architecture?
- Managing microservices with PM2
- Effective logging strategies
- Debugging Node.js applications
- Benchmarking performance
- Profiling code execution
- Knowing what to optimize
Skill Level Intermediate
Node.js: Deploying Applicationswith Kirsten Hunter1h 24m Intermediate
Building RESTful Web APIs with Node.js and Expresswith Emmanuel Henri1h 40m Intermediate
1. Build a Troubleshooting Mindset
2. Introducing Microservices
3. Effective Logging Strategies
4. Debugging Node.js Applications
Debugging isn't just logging3m 51s
5. Measuring Performance
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.