2012-07-20 60 views
0

我有一個芒果版WP7應用程序。當我通過應用程序部署工具將應用程序部署到手機時,我無法獲取錯誤日誌或日誌報告。我需要日誌來檢查後面發生的事情。這一點很重要。我怎樣才能做到這一點?有沒有辦法獲得記錄並獲取正在運行的應用程序的日誌?我使用記錄語句如下:手機從PC斷開時獲取錯誤日誌

#if LOG_ENABLED 
           Logger.log(TAG, "Client not received any UserId from server response.. so Exiting the application."); 
#endif 

和記錄器類是這樣實現的:

public static void log(string tag, string str) 
    { 
#if LOG_ENABLED 
     string strMsg= new StringBuilder().Append(DateTime.Now.ToShortDateString()).Append(" , ").Append(DateTime.Now.ToShortTimeString()).Append(" : ").Append(tag).Append(" : ").Append(str).ToString();    
     System.Diagnostics.Debug.WriteLine("Telus Application log : "+strMsg);   
     // LogOffline(strMsg); 
#endif 
    } 

internal static void log(Exception e) 
    { 
#if LOG_ENABLED 
     System.Diagnostics.Debug.WriteLine("Telus Application log : {0}", e.StackTrace); 
#endif 
    } 

我沒有問題,得到日誌的模擬器運行或者,即使應用程序部署時通過Visual Studio打電話。

謝謝! :)

回答

1

一個解決方案是將日誌寫入IsolatedStorage。然後,您可以通過使用IsolatedStorageTool來訪問IsolatedStorage,或者您可以將一個選項添加到應用程序中,以顯示它在應用程序中。

0

據我所知,System.Diagnostics.Debug.WriteLine只有當調試一個應用程序(當然Visual Studio中需要連接到Windows Phone模擬器或設備)輸出在Visual Studio輸出窗口中的消息。

+0

我收到日誌,並沒有問題。當設備(電話)未連接到VS時,我想獲取日誌。 – Apoorva 2012-07-20 10:43:44

+1

在這種情況下,你應該在@GnrlKnowledge所說的孤立存儲中寫入日誌。以下是如何讀取和寫入獨立存儲中的文本:http://www.windowsphonegeek.com/tips/all-about-wp7-isolated-storage-read-and-save-text-files。另一個解決方案是使用LittleWatson類。它將幫助您報告例外情況:http://blogs.msdn.com/b/andypennell/archive/2010/11/01/error-reporting-on-windows-phone-7.aspx – 2012-07-20 12:35:16

+0

Thnx !!! :)會嘗試。 – Apoorva 2012-07-20 13:34:31