Setting Android Log Levels

Can I set log levels on a device that is not deployed? so I want to somehow change the device log level to "debug". Is this something that can be done?

since its not rooted, I don't think setprop will work. I also cannot change the local.prop file, since I do not have permission to do this.

besides being lucky, and find a hidden menu that has log levels. is there any way to improve log level in another way?

thanks for the help.

+8
android
source share
2 answers

setprop :

  • is temporary until you reboot the device, even on root phones.
  • you can save properties through reboots if you write them in local.prop , which is possible only on root phones.
  • some properties are read-only and can only be changed when some init files change. This may not even be possible on root phones.
  • Each device (or firmware) may have a different set of properties. An rooted phone will not be automatically anymore.

logging levels:

  • If the code that prints the log says Log.d() , then it will be at the “debugging” level and you cannot change it unless you change the code and recompile it. There is nothing that hides log messages if you execute Log.? regardless of level.
  • The Android framework hides some log messages if you have a consolidated version of the firmware. To show them, you must recompile your firmware as a debug build. There is no chance to get them for display on the root phone.
  • some messages are controlled by a local variable in code like if (LOCAL_LOGV) Log.v(... - you need to change the code here to see them too.
  • some messages are controlled by Config.LOGV (= always false ) see Config . There is no way to change broken behavior. You need to recompile.
  • some other logmessages are hidden until you enable the property:

Example

 public static final boolean DEBUG_SQL_CACHE = Log.isLoggable("SQLiteCompiledSql", Log.VERBOSE); // somewhere in code if (SQLiteDebug.DEBUG_SQL_CACHE) { Log.d(TAG, "secret message!"); } 

if you do adb shell setprop log.tag.SQLiteCompiledSql VERBOSE , you should see these messages appear. Log # isLoggable ()

There is no global global level that I know of.

+12
source share

Let me suggest a small replacement for the standard journal class (I am the author)

https://github.com/zserge/log

It is backward compatible, so you only need to change your import. Then you can set the minimum log level for your application using Log.level(Log.D) or Log.level(Log.W) , etc., Or you can turn off the logs using Log.useLog(false) . No need to modify existing logging code.

Despite its small size, this registrar works with both the JVM and Android, allows you to skip the "tag" parameter, simplifies the logging of several values, separated by commas or using a format string. So it’s really convenient, easy to carry, and adds ~ 4 kilobytes to your APK size.

+2
source share

All Articles