Often when I develop a program I throw some console.writeline statements to let me know what the application is doing during debugging. Often time I find myself removing them and adding them back in in order to keep the code clean. I haven't found a seemingly efficient way to place these gracefully in the code.
I was wondering what other people do or what is considered a best practice for this. I am not sure if I can use trace or not because I am not debugging on a computer with Visual Studio installed (the server I am publishing to does not have it).
Is there any AOP based method to attack this? Ideally I would not want the output in production code because writing to the console seems to slow down the application.
Thanks in advance!
Have you looked at using Log4Net? It should be a lot more flexible for you. You can leave a lot of logging in the code, and turn it on or off based on a configuration loaded at execution time.
There are many options for logging out there. MS enterprise library and log4net are two very popular options. In each of these you can control the level of logging through the config file so that in dev you can have very verbose logging but in prod you can suppress all but the errors for example - all without changing code.
Also, if you need to debug a production problem you can turn verbose logging on in production simply by changing the config settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With