I am still looking at Android coding, but from what I have seen so far, I would suggest that Android logging suffers from the same problems that most Java logging mechanisms suffer (a notable exception is SLF4J), and exactly
- Logging affects performance because:
- This means calls to additional methods. (Not a problem for 99% of applications).
- This often means string assembly (big impact)
- It uses an extra IO (big hit)
Developers usually deal with this by adding protection blocks.
if (log.isDebugEnabled()) { log.debug("..."); }
I think the Android SDK can do this too. it closes # 2 and # 3, but still leaves your release code containing unused logging code. assuming, of course, that you never want to enable debug logging in a release situation.
SFL4J BTW does not require protective blocks because it used type C calls that delay the assembly of the String until it is needed. Unfortunately, it seems that Android has not taken this path. IOS does not have this problem either because it has a pre-compiler. Something that I often desire Java is preserved.
In any case, I would not advocate deleting the log in favor of the debugger. IMHO they serve two different purposes. Logging I find it very useful (if done correctly) in understanding the flow of the application. I often found problems by looking at logs that I would not find in the debugger. I.e. unnecessary code execution for several classes (especially in user interface classes), problems with odd data that do not actually lead to errors, etc. In these situations, using a debugger will resemble trying to lay concrete with a spoon. Debuggers, on the other hand, are ideal for analyzing the subtle details of a problem highlighted by a log.
Thus, in my code, I tend to have enough records that are designed to tell me what the application does in English so that I can easily read and understand what is happening. But I'm strict enough to keep levels as low as possible. I.e. do not record material at the information level, if this is not what you want to see even in release mode. I found that many developers tend to break this.
UPDATE: just read Delete all debugging error messages before posting: are there any tools for this? , which talks about how you can use ProGuard to prohibit registration from the release code. A great idea means that you canβt worry about blocking locks when you log in and bet as many as you want, but rest assured that your release code will be fast.