P
P
Pavel Tkachenko2018-03-13 14:21:37
Node.js
Pavel Tkachenko, 2018-03-13 14:21:37

Logging for Nodejs?

Good day, I'm doing a graduation project (accounting) on ​​nodejs, express and mongodb with mongoose, I've been struggling with the topic of logging for several days now.
What I need:
Application

  1. Process application logs (node ​​modules: error, warning, info).
  2. Store in a file and output to the console, store logs no older than a certain time.
  3. Log formatting (date, time, level, module, message).
Users
  1. Process user logs (has access to req, res)
  2. Custom levels
  3. Log formatting (date, time, user, level (login, logout, CRUD), message.
  4. It would also be nice to have formatting for each level
  5. Store in db.

Prompt a logger for implementation of similar functionality.
MB Am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Tkachenko, 2018-03-13
@Pavel_Tkachenko

Thank you, I already read this article ... Intel didn’t master it, I also didn’t figure it out with version 3, now I’m trying winston 2.4 , I’m trying to implement the necessary functionality with extensible features from the same developers: this is for mongodb and this is for files by day , and here is the guide to create multiple loggers. If successful, I'll post the implementation code here.

V
Vladimir Skibin, 2018-03-13
@megafax

As Andrey Tsvetkov already mentioned , the article, though already bearded (4 years after all). I am using winston packaged as a standalone module. It already has the level of what error I log - I figure out where it is (STDERR, base, etc.). For each error, you can generate your own output. I just use ver3 already, although it is RC, but ver2 is much more convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question