How to Disable logs at Component Integration , Application Integration and System Integration Phases

from the CommonsWare Community archives

At July 3, 2019, 11:33am, Ven asked:

I want to understand what are Component Integration , Application Integration and System Integration Phases in Android and how we can debug issues here(like disabling Logs)


At July 3, 2019, 11:44am, mmurphy replied:

I do not know what you mean by those terms, sorry.


At July 3, 2019, 11:50am, Ven replied:

ok, no problem
could you tell me how to enable/disable logs in different scenarios like

  1. Logs present in view / viewmodel /model
  2. Say , logs are present in View and view is connected to viewmodel / model ,in that case how to disable them

At July 3, 2019, 12:05pm, mmurphy replied:

In the end, you use an if statement:

if (weShouldLogThis) { Log.e(TAG, "Something went boom"); }

Some libraries may offer specific options for that sort of enabling/disabling of logs. Personally, I have only ever worried about it in terms of debug versus release builds, which usually can be handled by a single bit of configuration up front (e.g., using Timber). So, I have not been looking for libraries that provide some sort of per-situation toggling of whether logs get recorded or not.

If you do not wish to use a library, you will need to wrap your Log calls in if checks and have your own set of boolean values that track whether you should or should not be logging in a particular situation.