Skip to content
五月 6, 2011 / wychi

How to use log while do Android developing?

How to log?

To be able turn on/off log at run-time, we should utilize Android’s built-in log mechanism.

In code,

if( Log.isLoggable(constants.TAG, Log.DEBUG))

        Log.d(constants.TAG, message);

To see the log, you can switch the log level of specific tag.

wychi@and-desktop:~$ adb shell setprop log.tag.Test DEBUG

wychi@and-desktop:~$ adb logcat Test:* *:E

The code for log can be stripped at compile time by ProGuard. [Ref]

with a config like:

-assumenosideeffects class android.util.Log {

   publicstaticint v(…);



在下方填入你的資料或按右方圖示以社群網站登入: Logo

You are commenting using your account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )


You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: