mszabolcs
mszabolcs

Reputation: 67

JavaScript dialy logging system

I want to create a daily logging system for my project.
I'll overload the console.log() to make a line in the file and to output in the terminal.
For daily logging, we need something like a timer/time checker which checking if the date is another day.
What would be the best solution?
Example file:
jsproject_20180702.log

Upvotes: 0

Views: 42

Answers (1)

Sunil Gollapinni
Sunil Gollapinni

Reputation: 169

It depends on where you're planning to implement this functionality.

Preferred option is to use your server module to trigger/schedule a function which is executed everyday time interval.

Option 1 - Javascript :

Use setInterval(backupLoggingFn, 1000 * 60 * 60 * 24)

Option 2 - NPM :

You can look into most popular logging frameworks/libraries on NPM

Option 3 - Linux Server:

If your server is hosted on Linux server then you can do this by using simple bash script.

Upvotes: 1

Related Questions