What is the ideal code to logging ratio? I'm not used to writing logs as most of the applications I've developed have not had much logging.
Recently though I've changed job, and I've noticed that you can't see the application code for the calls to log4net. I appreciate that this is useful but surely having too many debug statements is just as bad as not having any at all?
There are logging statements that tell you when every method starts and finishes and what they are returning. and when pretty much anything is done.
Would it not be easier to have some addon that used reflection to add the logging statements in at compile time so they didn't get in the way as you were trying to look at the code?
Also in these days of powerful IDEs and remote debugging is that much logging really nescisary?
I think another factor is the toolset/platform being used and the conventions that come with it. For example, logging seems to be quite pervasive in the J(2)EE world, whereas I can't remember ever writing a log statement in a Ruby on Rails application.
I think "logs to code ratio" is a misunderstanding of the problem.
In my job I once in a while have a situation where a bug in a Java program cannot be reproduced outside the production environment and where the customer does NOT want it to happen again.
Then ALL you have available to you to fix the bug, is the information you yourself have put in the log files. No debugging sessions (that is forbidden in production environments anyway) - no poking at input data - nothing!
So the logs are your time machine back to when the bug happened, and since you cannot predict ahead of time what information you will need to fix a bug yet unknown - otherwise you could just fix the bug in the first place - you need to log lots of stuff...
Exactly WHAT stuff depends on the scenario, but basically enough to ensure that you are never in doubt what happens where :)
Naturally this means that a LOT of logging will happen. You will then create two logs - one with everything which is only kept around for long enough to ensure that you will not need it, and the other one with non-trivial information which can be kept for a lot longer.
Dismissing logging as excessive, is usually done by those who have not had to fix a bug with nothing else to go by :)