Reputation: 729
Is there a Logger.setLevel
-like method in the Android class Log
?
Upvotes: 0
Views: 777
Reputation: 59650
No there are no built in methods for this in Log class.[As per I know].
But you can build your own like:
public void setLevel(int level) {
switch (level) {
case OFF:
this.logger.setLevel(Level.OFF);
break;
case ALL:
this.logger.setLevel(Level.ALL);
break;
case INFO:
this.logger.setLevel(Level.INFO);
break;
case WARN:
this.logger.setLevel(Level.WARNING);
break;
case ERROR:
this.logger.setLevel(Level.SEVERE);
break;
default:
break;
}
}
Also You can change the default level by setting a system property: setprop log.tag.<YOUR_LOG_TAG> <LEVEL>
where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS.
You can also create a local.prop file that with the following in it: log.tag.<YOUR_LOG_TAG>=<LEVEL>
and place that in /data/local.prop. setprop log.tag.<YOUR_LOG_TAG> <LEVEL>
Upvotes: 0
Reputation: 64700
No. android.util.Log
relies on the log viewer to filter out the desired priority:logcat
lets you pick which severity you want (ASSERT/DEBUG/ERROR/INFO/VERBOSE/WARN).
Upvotes: 1