Logging, Better to Have It, Before You Need It
Motivation for Logging
Logging is the one thing you don’t know you need until you need it. I’m sure many of us have all been in the situation in which you wish you knew what your program was doing in a production environment. If only you could set a break point to check all of your variables and figure out why you can’t recreate it on your machine. One of the best solutions to this situation is logging! Good logging can often help you know exactly why that exception occurred. You can write logs as granular as you need. You can even set logging up so that different levels are logged based on a setting, either from a web.config file or a database. Some the reasons I can think of off the top of my head are:
- Debugging purposes
- Auditing user access
- Performance metrics
- Usability assessment
- Supplement to commenting your code
I stumbled across another blog by Erik Hazzard in which he goes into more detail about why logging is important. vasir.net/blog/development/how-logging-made-me-a-better-developer
Today I am going to show you my simple logging and audit solution. I know there are many enterprise level logging solutions out there, such as Log4Net, but those are over kill for my needs and writing this takes just as much time as integrating a third party framework. I am using Entity Framework with my ASP.NET MVC project. I am also using Unity for dependency … Continue reading