閱讀102 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Android開發3——查看和輸出日誌信息

一、錯誤級別

Error > Warn > Info > Debug > Verbose(冗餘)

 

 

二、Android項目日誌查看視圖

Console視圖隻能看項目的部署到模擬器上的信息,開發日誌信息隻能在LogCat視圖上看。在LogCat視圖上有按鈕可以進行錯誤級別的篩選。比如點擊Info按鈕,會顯示錯誤級別大於等於Info級別的日誌信息。

 

 

 

三、輸出日誌信息

	private final String tag = "xyLog";

	/**
	 * 方法一,推薦使用,可精確定義信息級別
	 */
	public void testLog1() throws Exception
	{
		String myname = "xy";
		Log.i(tag, myname); // 信息級別
		Log.e(tag, "err");  // 錯誤級別
		Log.e(tag, "錯誤"); // 中文在LogCat視圖中顯示亂碼,這是視圖的問題不是程序的問題
	}

	/**
	 * 方法二
	 */
	public void testLog2() throws Exception
	{
		// 信息級別
		System.out.println("xy");
	}

	/**
	 * 方法三
	 */
	public void testLog3() throws Exception
	{
		// 警告級別
		System.err.println("xy");
	}

上述信息會輸出到LogCat視圖上,供開發人員查看。

 

 

最後更新:2017-04-03 07:57:30

  上一篇:go Android開發7——android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
  下一篇:go iBatis和Hibernate的對比