Android系统中有哪些日志信息和工具

Android系统日志和工具

我们经常需要查看设备里面的各种日志信息。所以有必要了解android系统里面有哪些日志,以及用什么方式可以提取这些日志。以我手头的红米note4xplus为例,其基本配置为高通msm8953,android7.0。我们可以看一下根文件系统:

mido:/ # ls
acct              init.carrier.rc                      init.qcom.sh               root
bin               init.class_main.sh                   init.qcom.syspart_fixup.sh sbin
bt_firmware       init.environ.rc                      init.qcom.usb.rc           sdcard
cache             init.mdm.sh                          init.qcom.usb.sh           seapp_contexts
charger           init.miui.cust.rc                    init.rc                    selinux_version
config            init.miui.early_boot.sh              init.recovery.hardware.rc  sepolicy
cust              init.miui.google_revenue_share.rc    init.target.rc             service_contexts
d                 init.miui.google_revenue_share_v2.rc init.usb.configfs.rc       storage
data              init.miui.nativedebug.rc             init.usb.rc                sys
default.prop      init.miui.post_boot.sh               init.zygote32.rc           system
dev               init.miui.rc                         init.zygote64_32.rc        tombstones
dsp               init.msm.usb.configfs.rc             mnt                        ueventd.qcom.rc
etc               init.qcom.class_core.sh              oem                        ueventd.rc
file_contexts.bin init.qcom.early_boot.sh              persist                    unlock_key
firmware          init.qcom.factory.rc                 proc                       vendor
fstab.qcom        init.qcom.rc                         property_contexts          verity_key
init              init.qcom.sensors.sh                 res

以这个设备的文件系统为基础,我们来看一下一般的android设备中都有那些系统日志。

本文档只做日志相关的概要说明,不具体说明每个工具的使用方法。

android设备默认的命令一般都在/system/bin, /system/xbin和/sbin目录下。我们选择几个常用的命令来做个说明。

atrace

实际上就是systrace的代理。用来抓取用户空间服务日志信息。

一般用法:

adb shell atrace sched freq idle gfx view sync -b 96000 -f atrace.log

命令帮助:

adb shell atrace --help
usage: atrace [options] [categories...]
options include:
  -a appname      enable app-level tracing for a comma separated list of cmdlines
  -b N            use a trace buffer size of N KB
  -c              trace into a circular buffer
  -f filename     use the categories written in a file as space-separated
                    values in a line
  -k fname,...    trace the listed kernel functions
  -n              ignore signals
  -s N            sleep for N seconds before tracing [default 0]
  -t N            trace for N seconds [defualt 5]
  -z              compress the trace dump
  --async_start   start circular trace and return immediatly
  --async_dump    dump the current contents of circular trace buffer
  --async_stop    stop tracing and dump the current contents of circular
                    trace buffer
  --stream        stream trace to stdout as it enters the trace buffer
                    Note: this can take significant CPU time, and is best
                    used for measuring things that are not affected by
                    CPU performance, like pagecache usage.

  --list_categories
                  list the available tracing categories
 -o filename      write the trace to the specified file instead
                    of stdout.

所有的业务类型列表:

adb shell atrace --list_categories
         gfx - Graphics
       input - Input
        view - View System
     webview - WebView
          wm - Window Manager
          am - Activity Manager
          sm - Sync Manager
       audio - Audio
       video - Video
      camera - Camera
         hal - Hardware Modules
         app - Application
         res - Resource Loading
      dalvik - Dalvik VM
          rs - RenderScript
      bionic - Bionic C Library
       power - Power Management
          pm - Package Manager
          ss - System Server
    database - Database
       sched - CPU Scheduling
         irq - IRQ Events
        freq - CPU Frequency
        idle - CPU Idle
        disk - Disk I/O
         mmc - eMMC commands
        load - CPU Load
        sync - Synchronization
       workq - Kernel Workqueues
  memreclaim - Kernel Memory Reclaim
  regulators - Voltage and Current Regulators
  binder_driver - Binder Kernel driver
  binder_lock - Binder global lock trace
   pagecache - Page cache

bootstat

查看设备启动状态信息。

`
adb shell bootstat -p
Boot events:

Original: https://www.cnblogs.com/aosp/p/16411738.html
Author: 河东西望
Title: Android系统中有哪些日志信息和工具

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/582222/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球