欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Windows Phone实用开发技巧(22):使用日志记录信息与异常信息

程序员文章站 2022-07-03 18:38:42
what is logging ?  logging is the felling, skidding, on-site processing, and loading of trees...

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.
 Windows Phone实用开发技巧(22):使用日志记录信息与异常信息

Windows Phone实用开发技巧(22):使用日志记录信息与异常信息
 
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.
how to use it ?
first, we should add dll reference to our main project, shown as follow:

Windows Phone实用开发技巧(22):使用日志记录信息与异常信息
 
after that, we manually generate a dividebvzeroexception, shown as below:
 Windows Phone实用开发技巧(22):使用日志记录信息与异常信息
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.
 
 Windows Phone实用开发技巧(22):使用日志记录信息与异常信息

Windows Phone实用开发技巧(22):使用日志记录信息与异常信息
ok, it is very simple to use. you can find source code here.
作者“alexis的51博客”