SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Logging System of
     Android
      2010.8.27
      2010.9.2 updated


  Tetsuyuki Kobayashi

                         1
Who am I?

   20+ years involved in embedded systems
       10 years in real time OS, such as iTRON
       10 years in embedded Java Virtual Machine
       Now GCC, Linux, QEMU, Android, …
   Blogs
       http://d.hatena.ne.jp/embedded/ (Personal)
       http://blog.kmckk.com/ (Corporate)
   Twitter
       @tetsu_koba
                                                     2
Today's topic

   Log from Java program
   Log from native program
   Overview of Android Logging
    system
   Tips


                                  3
Log from Java program

   android.util.Log class
   System.out, System.err




                               4
android.util.Log

   Static methods
     Log.e, Log.w, Log.i, Log.d, Log.v


     e,w,i,d,v mean priority/log level


   writing log with tag, priority
   Tag and priority is used by filtering
       Static final String LOG_TAG = ”Hello”;
           ...
       Log.i(LOG_TAG, ”Hello to log”);
                                                5
System.out/System.err

   Default instance is
    com.android.internal.os.AndroidPri
    ntStream
   These connects to android.util.Log

       Tips: How to identify instance of System.out
          System.out.println(”System.out=” +
      System.out.toString());


                                                      6
Log from native program

   Use liblog library
   Include <android/log.h>
   __android_log_print
   Writing log with tag, priority
#include <android/log.h>
#define LOGI(...) 
__android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARG
S__)
        …
     LIGI(”i=%d, name=%sn”, i, name);
                                                    7
Stdout/stderr of native program

   These are NOT connected to logging
    system.
   Init process set stdout/stderr to
    /dev/null for its child processes.
   All Java processes, too.
      JNI native libs, too.


      Do not use printf (to stdout) in JNI

       native libs.                           8
How to read logs

   Logcat command
   Adb logcat
   Logcat pane in ADT, Eclipse
   Filtering by tag and priority




                                    9
Log device files

   4 channels, each have ring buffer
       /dev/log/radio – radio-related messages (64KB)
       /dev/log/event – system/hardware events (256KB)
       /dev/log/system – system/framwork messages (64KB)
       /dev/log/main – everything else (64KB)
   File permission of each is 0662
       owner/group RW, other Write only
       owner=root, group=log
       Anyone can write logs, root or log group can read
        them                                                10
Overview of Android Logging System
                                                                                    Target
                                  Java program
                                   Java program                    System.out
                                                                   /System.err

                                                       com.android.internal.os
       Native program             android.util.Log      com.android.internal.os               Host
        Native program             android.util.Log      AndroidPrintStream
                                                          AndroidPrintStream

                                                                                              ADT in Eclipse
                                                                                  stdout
                                                              logcat
                                                               logcat
       stdout          liblog
       /stderr           liblog                                                                adbserver
                                                                                  adbd
                                                                                   adbd         adbserver
User

Kernel                                                                                         adb logcat

                                  main     64KB       radio
                                            logger
                                             logger           64KB
         /dev/log/main                                                      /dev/log/main
         /dev/log/radio            event                                    /dev/log/radio
                                                      system
         /dev/log/event                     256KB                           /dev/log/event
         /dev/log/system                                      64KB          /dev/log/system            11
Where to read in source code
   android.util.Log
        frameworks/base/core/java/android/util/Log.java
   com.android.internal.os.AndroidPrintStream
        frameworks/base/core/java/com/android/internal/os/Android
         PrintStream.java
   Liblog
        system/core/liblog/
   Logcat command
        system/core/logcat/
   Adb command
        system/core/adb/
   Kernel log driver
                                                                     12
        drivers/staging/android/logger.c
Tips

   Dumping stack trace
   Character Encoding
   Logwrapper
   Log at init process



                          13
Dumping stack trace

   3 arguments fuctions in android.util.Log
    class
                                   You can put 'new Throwable()'
       For example:
       Log.e(String tag, String msg, Throwable tr)
   Throwable.printStacktrace() also works
       Dump to System.err
   See also
       http://blog.kmckk.com/archives/2902690.html
                                                                   14
Character Encoding
   Fixed to Utf-8
       Not Shift-JIS, Not EUC
   Use Utf-8 encoding terminal/window to
    use logcat
       adb logcat
       invoke 'logcat' at serial console
   Logcat pane in ADT in Eclipse seems bug.
       Can not show Japanese character correctly.

                                                     15
Logwrapper

   Logwrapper redirects stdout/stderr to
    Android Logging system
   Easy way to add 'usual' command as
    Android service lunched from init.
   See also
       http://blog.kmckk.com/archives/2918551.html



                                                  16
Log at init process

   The first process 'init' does not use
    Android Logging System.
   Init writes log to (the same node as)
    '/dev/kmsg'
       The same way as 'printk' : kernel log




                                                17
Q&A




Thank you for listening!
Any comments to blogs are welcome.

                                     18

Mais conteúdo relacionado

Mais procurados

ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
Tetsuyuki Kobayashi
 
X / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural OverviewX / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural Overview
Moriyoshi Koizumi
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 

Mais procurados (20)

Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
GPU Acceleration for Containers on Intel Processor Graphics
GPU Acceleration for Containers on Intel Processor GraphicsGPU Acceleration for Containers on Intel Processor Graphics
GPU Acceleration for Containers on Intel Processor Graphics
 
DynamoDBによるソーシャルゲーム実装 How To
DynamoDBによるソーシャルゲーム実装 How ToDynamoDBによるソーシャルゲーム実装 How To
DynamoDBによるソーシャルゲーム実装 How To
 
Android binder-ipc
Android binder-ipcAndroid binder-ipc
Android binder-ipc
 
X / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural OverviewX / DRM (Direct Rendering Manager) Architectural Overview
X / DRM (Direct Rendering Manager) Architectural Overview
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Windows Server 2019 で Container を使ってみる
Windows Server 2019 で Container を使ってみるWindows Server 2019 で Container を使ってみる
Windows Server 2019 で Container を使ってみる
 
Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)
 
Android Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and OrganizationAndroid Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and Organization
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道 淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 

Destaque (8)

QEMU in Cross building
QEMU in Cross buildingQEMU in Cross building
QEMU in Cross building
 
Android On Ubuntu for developer
Android On Ubuntu for developerAndroid On Ubuntu for developer
Android On Ubuntu for developer
 
Froyo DalvikVM JIT
Froyo DalvikVM JITFroyo DalvikVM JIT
Froyo DalvikVM JIT
 
Reusing your existing software on Android
Reusing your existing software on AndroidReusing your existing software on Android
Reusing your existing software on Android
 
Using QEMU for cross development
Using QEMU for cross developmentUsing QEMU for cross development
Using QEMU for cross development
 
Android ipm 20110409
Android ipm 20110409Android ipm 20110409
Android ipm 20110409
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Tricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft floatTricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft float
 

Semelhante a Logging system of Android

Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
James Hsieh
 
HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
Linaro
 

Semelhante a Logging system of Android (20)

Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android OS Porting: Introduction
Android OS Porting: IntroductionAndroid OS Porting: Introduction
Android OS Porting: Introduction
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Logging & Metrics with Docker
Logging & Metrics with DockerLogging & Metrics with Docker
Logging & Metrics with Docker
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
App container rkt
App container rktApp container rkt
App container rkt
 
HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Linux on System z debugging with Valgrind
Linux on System z debugging with ValgrindLinux on System z debugging with Valgrind
Linux on System z debugging with Valgrind
 
SEMLA_logging_infra
SEMLA_logging_infraSEMLA_logging_infra
SEMLA_logging_infra
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
Eric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyondEric Lafortune - Fighting application size with ProGuard and beyond
Eric Lafortune - Fighting application size with ProGuard and beyond
 

Mais de Tetsuyuki Kobayashi

Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
Tetsuyuki Kobayashi
 

Mais de Tetsuyuki Kobayashi (20)

some topic of ffmpeg
some topic of ffmpeg some topic of ffmpeg
some topic of ffmpeg
 
New VIdeo CODEC AV1
New VIdeo CODEC AV1 New VIdeo CODEC AV1
New VIdeo CODEC AV1
 
Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT  (ver. 2)Try new transport protocol SRT  (ver. 2)
Try new transport protocol SRT (ver. 2)
 
Try new transport protocol SRT
Try new transport protocol SRTTry new transport protocol SRT
Try new transport protocol SRT
 
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
 
WebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたWebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみた
 
Linuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くLinuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書く
 
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)
 
組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ
 
ARM 64bit has come!
ARM 64bit has come!ARM 64bit has come!
ARM 64bit has come!
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
 
Tips of Malloc & Free
Tips of Malloc & FreeTips of Malloc & Free
Tips of Malloc & Free
 
Basic of virtual memory of Linux
Basic of virtual memory of LinuxBasic of virtual memory of Linux
Basic of virtual memory of Linux
 
Patch101
Patch101Patch101
Patch101
 
Tweaking Google TV emulator
Tweaking Google TV emulatorTweaking Google TV emulator
Tweaking Google TV emulator
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of Android
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
 
Init of Android
Init of AndroidInit of Android
Init of Android
 
Let's play with Goldfish
Let's play with GoldfishLet's play with Goldfish
Let's play with Goldfish
 

Último

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Logging system of Android

  • 1. Logging System of Android 2010.8.27 2010.9.2 updated Tetsuyuki Kobayashi 1
  • 2. Who am I?  20+ years involved in embedded systems  10 years in real time OS, such as iTRON  10 years in embedded Java Virtual Machine  Now GCC, Linux, QEMU, Android, …  Blogs  http://d.hatena.ne.jp/embedded/ (Personal)  http://blog.kmckk.com/ (Corporate)  Twitter  @tetsu_koba 2
  • 3. Today's topic  Log from Java program  Log from native program  Overview of Android Logging system  Tips 3
  • 4. Log from Java program  android.util.Log class  System.out, System.err 4
  • 5. android.util.Log  Static methods  Log.e, Log.w, Log.i, Log.d, Log.v  e,w,i,d,v mean priority/log level  writing log with tag, priority  Tag and priority is used by filtering Static final String LOG_TAG = ”Hello”; ... Log.i(LOG_TAG, ”Hello to log”); 5
  • 6. System.out/System.err  Default instance is com.android.internal.os.AndroidPri ntStream  These connects to android.util.Log Tips: How to identify instance of System.out System.out.println(”System.out=” + System.out.toString()); 6
  • 7. Log from native program  Use liblog library  Include <android/log.h>  __android_log_print  Writing log with tag, priority #include <android/log.h> #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARG S__) … LIGI(”i=%d, name=%sn”, i, name); 7
  • 8. Stdout/stderr of native program  These are NOT connected to logging system.  Init process set stdout/stderr to /dev/null for its child processes.  All Java processes, too.  JNI native libs, too.  Do not use printf (to stdout) in JNI native libs. 8
  • 9. How to read logs  Logcat command  Adb logcat  Logcat pane in ADT, Eclipse  Filtering by tag and priority 9
  • 10. Log device files  4 channels, each have ring buffer  /dev/log/radio – radio-related messages (64KB)  /dev/log/event – system/hardware events (256KB)  /dev/log/system – system/framwork messages (64KB)  /dev/log/main – everything else (64KB)  File permission of each is 0662  owner/group RW, other Write only  owner=root, group=log  Anyone can write logs, root or log group can read them 10
  • 11. Overview of Android Logging System Target Java program Java program System.out /System.err com.android.internal.os Native program android.util.Log com.android.internal.os Host Native program android.util.Log AndroidPrintStream AndroidPrintStream ADT in Eclipse stdout logcat logcat stdout liblog /stderr liblog adbserver adbd adbd adbserver User Kernel adb logcat main 64KB radio logger logger 64KB /dev/log/main /dev/log/main /dev/log/radio event /dev/log/radio system /dev/log/event 256KB /dev/log/event /dev/log/system 64KB /dev/log/system 11
  • 12. Where to read in source code  android.util.Log  frameworks/base/core/java/android/util/Log.java  com.android.internal.os.AndroidPrintStream  frameworks/base/core/java/com/android/internal/os/Android PrintStream.java  Liblog  system/core/liblog/  Logcat command  system/core/logcat/  Adb command  system/core/adb/  Kernel log driver 12  drivers/staging/android/logger.c
  • 13. Tips  Dumping stack trace  Character Encoding  Logwrapper  Log at init process 13
  • 14. Dumping stack trace  3 arguments fuctions in android.util.Log class You can put 'new Throwable()'  For example:  Log.e(String tag, String msg, Throwable tr)  Throwable.printStacktrace() also works  Dump to System.err  See also  http://blog.kmckk.com/archives/2902690.html 14
  • 15. Character Encoding  Fixed to Utf-8  Not Shift-JIS, Not EUC  Use Utf-8 encoding terminal/window to use logcat  adb logcat  invoke 'logcat' at serial console  Logcat pane in ADT in Eclipse seems bug.  Can not show Japanese character correctly. 15
  • 16. Logwrapper  Logwrapper redirects stdout/stderr to Android Logging system  Easy way to add 'usual' command as Android service lunched from init.  See also  http://blog.kmckk.com/archives/2918551.html 16
  • 17. Log at init process  The first process 'init' does not use Android Logging System.  Init writes log to (the same node as) '/dev/kmsg'  The same way as 'printk' : kernel log 17
  • 18. Q&A Thank you for listening! Any comments to blogs are welcome. 18