Android中使用logwrapper來重定向應用程序的標准輸出


  在Android應用程序調試中,有時候第三方應用程序的日志輸出是通過printf之類的標准函數輸出的,logcat不能捕獲這些日志,一個方法是使用logwrapper命令來執行第三方應用程序,logwrapper命令可以把第三方應用程序的標准輸出重定向到logcat的日志系統中去(缺省級別為LOG_INFO,標簽為應用程序名)。

  logwrapper的Usage如下:
  Usage: logwrapper [-a] [-d] [-k] BINARY [ARGS ...]

  Forks and executes BINARY ARGS, redirecting stdout and stderr to the Android logging system. Tag is set to BINARY, priority is always LOG_INFO.

  -a: Causes logwrapper to do abbreviated logging. This logs up to the first 4K and last 4K of the command being run, and logs the output when the command exits
  -d: Causes logwrapper to SIGSEGV when BINARY terminates fault address is set to the status of wait()
  -k: Causes logwrapper to log to the kernel log instead of the Android system log

 

  例如,在adb shell下

  root@android:/ ps

  ps的結果只在當前控制台下輸出,要想把ps的結果輸出到adb log中去,可以使用:

  root@android:/ logwrapper ps

  這樣adb logcat就能捕獲到ps的輸出了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM