So far, I have not thought about any extensive logging tool for my Node.js applications. I knew there were several logging tools available, but I was using only the regular console.log feature in my Node.js application. The reason why I wanted Pino was because of the wide features that it gave me, apart from the regular logging. I explored other similar applications that did the logging and ended up with pino for its simplicity and ease of migration.
I had completed my application already with console.log, and then I thought I would create a schema for logs and maintain it in the database. Then, after reading a few articles, they suggested that having the logs inside the database is not an advisable approach. People say that saving it in a file is better than saving it in the database. But I noticed that different people have different views on that, but I find saving it in a file suitable for my needs.
We have a feature to define the log level, which means I can define where my log is an error or info or warning, etc. Based on the type of log, I can also filter it out. Another interesting feature is that the log can be printed in JSON format, which can later be processed into any form we want. There are also tools available that can read from this log file and show it to us in a desired format.
Troubleshooting becomes easier if we have this type of logging. I can simply do a console.log statement, but having it in a structured format helps in troubleshooting in enterprise applications. Pino package is also type safe, and we can use it in our modern development. The setup of the package was also not a headache. I had to just include the package and add a logger.js file (in my case, it was a .ts file) and have the configuration done in that file.
Pino also has a facility where the logs can either be logged in the console itself or it can be saved in a separate log file. Additionally, if required, we can also save the log in multiple places. The default fields available in the configuration itself are sufficient enough but if we would like to customize the configuration, we can do it.
Another important feature that Pino gives is the ability to filter out sensitive information from logging. If the log data is going to be structured, we can easily eliminate the sensitive data and show only the necessary data.
If you like what I'm doing on Hive, you can vote me as a witness with the links below.
Posted Using INLEO
This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.
Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight.
Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.
100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited..
This post received an extra 20.00% vote for delegating HP / holding IUC tokens.
at my work place we have both file log and database log... file log is tedious, you need to to grep to search if you are on linux, then you have retention and lose files... database is easier, you do a select, you can keep more log than files as it takes less space
With the help of such software, we can save our data and because we forget our passwords and then later we have problems or even if our mobile is stolen, then we still cannot get our data.
Congratulations @bala41288! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts:
This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.
Do you know that you can earn a passive income by delegating your Leo power to @india-leo account? We share 100 % of the curation rewards with the delegators.
100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited.
That’s actually super useful, keeping sensitive info out of logs is a must, especially for compliance and security.
As far as it is safe, I think it is good for login I must confess
Congratulations @bala41288! You received a personal badge!
Wait until the end of Power Up Day to find out the size of your Power-Bee.
May the Hive Power be with you!
You can view your badges on your board and compare yourself to others in the Ranking
Check out our last posts: