windows-phone-8.1 – 如何在Windows Phone 8.1中收集应用程序日
发布时间:2020-12-14 01:57:12 所属栏目:Windows 来源:网络整理
导读:我是 Windows手机平台的新手.有什么可用的东西像android中的logcat用于收集日志吗?提前感谢. 解决方法 Windows 8.1引入了新类来简化日志记录.这些课程分别为 LoggingChannel,LoggingSession和 others. 这是一个例子: App.xaml.cs LoggingSession logSessio
我是
Windows手机平台的新手.有什么可用的东西像android中的logcat用于收集日志吗?提前感谢.
解决方法
Windows 8.1引入了新类来简化日志记录.这些课程分别为
LoggingChannel,LoggingSession和
others.
这是一个例子: App.xaml.cs LoggingSession logSession; LoggingChannel logChannel; public App() { this.InitializeComponent(); this.UnhandledException += App_UnhandledException; } void App_UnhandledException(object sender,UnhandledExceptionEventArgs e) { logChannel.LogMessage("Unhandled exception: " + e.Message); logSession.SaveToFileAsync(Windows.Storage.ApplicationData.Current.LocalFolder,"MainLog.log").AsTask().Wait(); } protected override void OnLaunched(LaunchActivatedEventArgs e) { logSession = new LoggingSession("MainLogSession"); Resources["MainLogSession"] = logSession; logChannel = new LoggingChannel("AppLogChannel"); logSession.AddLoggingChannel(logChannel); } MainPage.xaml.cs中 LoggingChannel logChannel; public MainPage() { this.InitializeComponent(); var logSession = (LoggingSession)Application.Current.Resources["MainLogSession"]; logChannel = new LoggingChannel("MainPageLogChannel"); logSession.AddLoggingChannel(logChannel); logChannel.LogMessage("MainPage ctor",LoggingLevel.Information); } 我强烈建议在2013年的构建会议期间观看Making your Windows Store Apps More Reliable主题演讲,其中Harry Pierson更详细地演示了这些新API(包括使用后台任务将日志文件上传到后端服务器,后台任务在手机连接到交流电源时执行). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 即指即现:为Windows 7任务栏预览提速
- windows-runtime – 将图像添加到MapControl的高
- Windows服务 – VS 2012:Windows服务中的“添加
- 模拟和Win32 API调用
- Windows – Docker Machine无法使用hyperv成功访
- 是否可以在Windows 7上使用PhoneGap开发iOS应用程
- windows-server-2008 – 我如何创建灵活的EC2 Wi
- windows-xp – 适用于Windows XP的最佳网络防病毒
- .net – 强制Windows显示系统托盘图标
- Microsoft如何决定在C#中使用static / member?
热点阅读