Android的设置日志级别 [英] Setting Android Log Levels

查看:2953
本文介绍了Android的设置日志级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置设备上的日志级别的根源并非是? 所以我想以某种方式改变设备的日志级别设置为调试。这事可以做?

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?

因为它不是源于我不认为setprop会工作。 我也改变不了local.prop文件,因为我没有权限这么做。

since its not rooted i dont think setprop will work. i can also not change the local.prop file since i do not have permissions to do so.

比可能得到幸运,找到一个隐藏的菜单有日志级别在里面等。 有没有办法对我来说,提升日志级别,一些其他的方式?

other than maybe getting lucky and finding a hidden menu that has the log levels in it. is there a way for me to enhance the log level some other way?

感谢您的帮助。

推荐答案

setprop

  • 是临时的,直到你重新启动您的设备,即使是在扎根手机。
  • 您可以通过重新启动,如果你把它们写入 local.prop 这是唯一可能在植根手机持续性。
  • 在某些属性是只读的,如果你改变一些初始化文件只能被改变。这可能是甚至是不可能的植根手机。
  • 在每个设备(或固件)可以有不同的属性集。有根的手机就不会自动多。
  • is temporary until you reboot your device, even on rooted phones.
  • you can persist properties through reboots if you write them into local.prop which is only possible on rooted phones.
  • some properties are read-only and can only be changed if you change some init files. That might be even impossible on rooted phones.
  • each device (or firmware) can have a different set of properties. A rooted phone wouldn't have automatically more.

记录等级:

  • 如果是打印记录的code说 Log.d()那么这将是在调试水平,你不能改变,除非你改变code和重新编译它。没有什么隐藏日志消息如果您执行登录?不分级别。
  • Android框架隐藏了一些日志信息,如果你有你的固件的发布版本。为了显示那些你需要重新编译固件调试版本。没有机会得到那些无论是在根深蒂固的手机显示。
  • 在一些消息是由在code像的局部变量控制的,如果(LOCAL_LOGV)Log.v(... - 你需要更改code在这里看到这些了。<​​/ LI>
  • 在一些消息是由 Config.LOGV 控制(=总是)看到的Config 。没有办法改变破碎行为,在这里无论是。你需要重新编译。
  • 在其他一些日志消息被隐藏,直到您启用一个属性:
  • If the code that prints the log says Log.d() then it will be on "debug" level and you can't change that unless you change the code and recompile it. There is nothing that hides log messages if you execute a Log.? regardless of level.
  • the Android framework hides some log messages if you have a release build of your firmware. To show those you need to recompile your firmware as debug build. No chance to get those to show on a rooted phone either.
  • some messages are controlled by a local variable in the code like if (LOCAL_LOGV) Log.v(... - you need to change the code here to see those too.
  • some messages are controlled by Config.LOGV (= always false) see Config. No way to change the broken behaviour here either. You need to recompile.
  • some other logmessages are hidden until you enable a property:

例如

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!");
}

如果您亚行外壳setprop log.tag.SQLiteCompiledSql VERBOSE 您应该看到这些消息弹出。 <一href="http://developer.android.com/reference/android/util/Log.html#isLoggable%28java.lang.String,%20int%29">Log#isLoggable()

if you do adb shell setprop log.tag.SQLiteCompiledSql VERBOSE you should see those messages popping up. Log#isLoggable()

没有全球性的日志级别,我知道的。

There is no global loglevel I know of.

这篇关于Android的设置日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆