如何在Windows 8 METRO应用程序中实现错误日志记录?

3

你好,我正在开发一个 Windows 8 C#/XAML Metro应用程序。

我希望在我的应用程序中实现错误日志记录,并以更好的方式处理错误日志。

1)如何记录错误信息(以便开发人员纠正错误)?

2)有没有第三方工具/免费库可用于Metro应用程序的错误日志记录?

3)有哪些可用于错误日志记录的其他选择?

4)错误日志记录的最佳惯例是什么?

请给予帮助。

您的答案将对我非常有帮助。

提前致谢。

2个回答

4

针对Windows 8.1,您可以使用新的Windows.Foundation.Diagnostics功能来记录LoggingSession和LogginChannel。

http://code.msdn.microsoft.com/windowsapps/LoggingSession-Sample-ccd52336 参见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
微软提供了一个记录示例,也许这会帮助你入门。
这篇博客文章中,作者列出了一些设置Windows 8商店应用程序日志记录的起点,以及一种自制解决方案。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接