How to implement Error Logging in Windows 8 METRO application?

此生再无相见时 提交于 2019-12-10 18:53:15

问题


Hi i am developing an windows 8 c#/xaml Metro application.

i want to implement error logging in my app. I want to handle error logs in better way.

1) How can log the error information(so that it will be helpful for the developer to rectify the error)

2)Are there any 3rd party tools / free library's for error logging in metro apps.

3)What are the various alternatives available for error logging ??

4)What is the best followed practice for error logging ??

Please help me out.

Your answer will be very helpful to me.

Thanks in advance.


回答1:


For Windows 8.1 you can use the new Windows.Foundation.Diagnostics functionality of LoggingSession and LogginChannel.

http://code.msdn.microsoft.com/windowsapps/LoggingSession-Sample-ccd52336 See BUILD-session: http://channel9.msdn.com/Events/Build/2013/3-136

var channel = new LoggingChannel ("ChannelName");
var session = new LoggingSession("Session Name");
session.AddLoggingChannel(channel, LoggingLevel.Warning);

channel.LogMessage("Message to log", LoggingLevel.Error);
channel.LogValuePair("Count", 42, LoggingLevel.Error);

//when error detected, save the log session to disk
var logFile = await session.SaveToFileAsync(ApplicationData.Current.LocalFolder, "CrashLog");



回答2:


Microsoft provide a sample for logging maybe this will get you started.

In this blog post the author names some starting points for setting up logging in a Windows8 Store App, as well as a homebrewed solution.



来源:https://stackoverflow.com/questions/15570364/how-to-implement-error-logging-in-windows-8-metro-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!