What are the best practices to log an error?
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