Skip to Content
Android Developer Tools深入精要
book

Android Developer Tools深入精要

by Mike Wolfson
July 2014
Intermediate to advanced
248 pages
5h 19m
Chinese
GoTop Information, Inc.
Content preview from Android Developer Tools深入精要
Logcat
|
83
第七章:測試程式碼
第七章
測試程式碼
[Page-89]
Logcat
Android
平台提供一個名為
logcat
的記錄日誌(
log
)機制,用來收集與檢視系統資訊。
從系統以及各種
app
產生的日誌會輸出至一組緩衝區中,而可以經由
logcat
指令來查
看及過濾。若你曾使用過
Log4J
或是
java.util.logging
套件則會感到非常熟悉。你可以
在一個地方裡檢視多個不同系統的輸出日誌,且可將它過濾來查看與自己應用程式相
關的資訊。這很值得去了解其中每個選項,這會讓開發更輕鬆。
Android
記錄幾乎所有系統中的事件到一個日誌檔案。一些資訊有關於垃圾回收、各種
系統的活動以及
app
的輸出都是記錄在相同的檔案,這將各式各樣的訊息匯集在單一
個地方。有一點很重要需注意的是這日誌檔案是與所有安裝在裝置上的
app
共享的,
所以要小心不要將敏感的資料輸出至日誌中。你可以利用
ProGuard
工具來混淆你的程
式碼,隱藏某些細節。當要發佈
app
時,這工具也可以用來移除
log
語句(更多使用此
工具的細節可以在第
135
頁「
ProGuard
」找到)。
查看日誌文件
要查看完整的日誌文件(無任何濾除)可以執行指令:
adb logcat
這會輸出非常冗長的日誌,包括與所有系統上處理程序有關的資訊。
日誌訊息的組成
每個日誌訊息包含數種中繼資料(
metadata
)而可以被過濾輸出。
84
|
第七章:測試程式碼
[Page-90]
日誌層級(
level
app
的角度來指出此則日誌回報的重要程度。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Android 高效能多執行緒

Android 高效能多執行緒

Anders Goransson
深入淺出 jQuery

深入淺出 jQuery

Ryan Benedetti, Ronan Cranley
HTML5 錦囊妙計

HTML5 錦囊妙計

Christopher Schmitt, Kyle Simpson

Publisher Resources

ISBN: 9789863470861