我有一个适用于mango版本的WP7应用程序。当我通过应用程序部署工具将应用程序部署到手机时,我无法获得错误日志或日志报告。我需要日志来检查后面发生了什么。这很重要。我怎样才能做到这一点?有没有办法获取正在运行的应用程序的记录和日志?我使用记录器语句如下:
#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部署在手机上,我也可以获得日志。
谢谢!!:)
一种解决方案是将日志写入IsolatedStorage。然后,您可以使用IsolatedStorage Tool访问IsolatedStore,也可以在应用程序中添加一个选项,该选项将显示在应用程序上。
据我所知,System.Diagnostics.Debug.WriteLine
仅在调试应用程序时在Visual Studio输出窗口中输出消息(当然,Visual Studio需要连接到Windows Phone模拟器或设备)。