Windows Phone 实用开发技巧(22):使用日志记录当前信息与异常信息
What is logging ?
Logging is the felling, skidding, on-site processing, and loading of trees or logs onto trucks. And since windows phone is much more event driven. you can find more information in Event Logging.
Why to use logging ?
Exception is everywhere in common software development. A good logging tool may helps a lot in solving problems. Here I recommend logging tool in WP7Contrib.
Here I created a helper class to do better and easier logging.
We can log common information as well as Exception simply by pass different parameter. We can also log device information since it may be help in finding which device goes wrong.
First, we should add dll reference to our main project, shown as follow:
After that, we manually generate a DivideBvZeroException, shown as below:
Here, I use LoggingHelper(shown before) class to log exception.As we run the app, we can find exception both in output and log.dat which is the file store logging.
Ok, it is very simple to use. you can find source code here.
如果您喜欢我的文章,您可以通过支付宝对我进行捐助,您的支持是我最大的动力https://me.alipay.com/alexis
作者:Alexis
出处:http://www.cnblogs.com/alexis/
关于作者:专注于Windows Phone 7、Silverlight、Web前端(jQuery)。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题,可以通过shuifengxuATgmail.com 联系我,非常感谢。