Setting Android Log Levels

后端 未结 2 1421
忘了有多久
忘了有多久 2021-02-08 11:54

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

2条回答
  •  情书的邮戳
    2021-02-08 12:00

    Let me suggest a tiny replacement for the standard log class (I'm the author)

    https://github.com/zserge/log

    It's backwards compatible, so you only need to modify your imports. Then you can set the minimal log level for your app via Log.level(Log.D) or Log.level(Log.W) etc, or you can disable logs using Log.useLog(false). No need to modify your existing logging code.

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

提交回复
热议问题