android Log.isLoggable步驟的使用

來源:互聯網
上載者:User

標籤:android   style   blog   os   使用   for   檔案   sp   div   

android Log.isLoggable方法的使用

android 動態控制logcat日誌開關,通過Log.isLoggable(TAG,level)方法動態控制,
1.添加日誌的時候加入判斷,
        String TAG="Volley";
        boolean isDbug=Log.isLoggable(TAG, Log.VERBOSE);
        if (isDbug) {
            Log.w(TAG, "log");
        }
2.通過設定屬性值來控制該日誌開關。

        在pc上,cmd->目錄指向adb.exe(D:\android\adt-bundle-windows-x86-20131030\sdk\platform-tools)->adb shell setprop log.tag.Volley VERBOSE 設定該TAG的輸出層級為VERBOSE。 則Log.isLoggable("Volley", Log.VERBOSE) level為VERBOSE以上的都返回true,每設定一次,只能用於一部手機沒有重啟的情況,如果換一部或者重啟要重新設定一下;這樣的好處是,自己開發的手機設定一次,都能列印VERBOSE,編譯給別的手機就不能列印VERBOSE資訊,這樣就不用每次正式發布時要把isDbug設定為false
        該屬性值取值順序為【V,D,I,W,E,A,S】 A表示最進階別的日誌,即assert;S表示Suppress,即停止該日誌的輸出。

也可以將該屬性添加在data/local.prop屬性檔案中,不同的是,只要存在local.prop,該手機重啟與否都一樣,可以列印VERBOSE

android Log.isLoggable步驟的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.