C# 手机与PC断开连接时获取错误日志
我有一个适用于芒果版本的WP7应用程序。当我通过应用程序部署工具将应用程序部署到手机上时,我无法获取错误日志或日志报告。我需要日志来检查后面发生了什么。这很重要。我怎样才能做到这一点?有没有办法获取正在运行的应用程序的记录和日志?Am使用记录器语句,如下所示:C# 手机与PC断开连接时获取错误日志,c#,windows-phone-7,logging,windows-phone-7.1,C#,Windows Phone 7,Logging,Windows Phone 7.1,我有一个适用于芒果版本的WP7应用程序。当我通过应用程序部署工具将应用程序部署到手机上时,我无法获取错误日志或日志报告。我需要日志来检查后面发生了什么。这很重要。我怎样才能做到这一点?有没有办法获取正在运行的应用程序的记录和日志?Am使用记录器语句,如下所示: #if LOG_ENABLED Logger.log(TAG, "Client not received any UserId from server response..
#if LOG_ENABLED
Logger.log(TAG, "Client not received any UserId from server response.. so Exiting the application.");
#endif
logger类的实现方式如下:
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
}
当模拟器运行时,或者即使应用程序通过VisualStudio部署在手机上,我也可以获取日志
谢谢!!:) 据我所知,
System.Diagnostics.Debug.WriteLine
仅在调试应用程序时在Visual Studio输出窗口中输出消息(当然Visual Studio需要连接到Windows Phone模拟器或设备)。一种解决方案是将日志写入隔离存储。然后,您可以使用IsolatedStorageTool访问IsolatedStorage,也可以在应用程序中添加一个在应用程序中显示的选项。我正在获取日志,这没有问题。我想在设备(电话)未连接到VS时获取日志。在这种情况下,您应该像@GnrlKnowledge所说的那样在隔离存储中写入日志。以下是如何在独立存储中读取和写入文本:。另一个解决方案是使用LittleWatson类。它将帮助您报告异常: