Perfomance & ScalingLesson 83Free preview
Node Logging
This lesson is part of Node.js · All levels
Summary
This lesson discusses logging on the application, from native P1 to libraries such as Winston and Pino. You'll learn to select the log levels (error, warn, info, debug), write the structured log in JSON format, and rotate the file so that storage remains under control. The neatness makes the investigation of the incident much faster. (Node.js)
Key points
- Level log in sequence: error > warn > info > debug > trace; set threshold according to environment.
- Console.log is only suitable for local debugging; production requires a structured log.
- General libraries: Winston (flexible, with lots of transport) and Pino (very fast, JSON).
- JSON is easy to search for and analyze by tools (ELK, CloudWatch).
- Rotation (e.g. winston-daily-rotate-file) prevents the file from swelling.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.