Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the best practices to log an error?

best practices Error log
0
Posted

What are the best practices to log an error?

0

Logging directly to the console is horrendous and frankly, the mark of a bad developer. The only reason to do this sort of thing is 1) he or she is unaware of other approaches, and/or 2) the developer has not thought one bit about what will happen when his/her code is deployed to a production site, and how the application will be maintained at that point. Dealing with an application that is logging 1GB/day or more of completely unneeded debug logging is maddening. The generally accepted best practice is to use a Logging framework that has concepts of: • Different log objects – Different classes/modules/etc can log to different loggers, so you can choose to apply different log configurations to different portions of the application. • Different log levels – so you can tweak the logging configuration to only log errors in production, to log all sorts of debug and trace info in a development environment, etc. • Different log outputs – the framework should allow you to configure where the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123