cf.net exception and other logging

扶醉桌前 提交于 2019-12-10 23:25:27

问题


I want to add some logging capability to a cf.net application running on WM6 Pro. I'm looking at logging exceptions and some of the more sensitive sections of code. I would like to have logs stored both locally (i.e. on the device) and also have them reliably uploaded to a server as well (they will need to be queued, my app is occasionally connected).

Does anyone know if this possible with log4net or will I have to write my own logging system? Does anyone have any pointers?


回答1:


If you use log4net for this, DO NOT use the UDP appender option to log to a remote server. If the WM device is connected to a PC via ActiveSync and accessing the net through the PC, attempting to use UDP will crash ActiveSync in a way that requires a reboot of the PC and a soft reset of the WM device. I had a demo go horribly wrong because of this (we lost a huge contract).

log4net may be great in other environments, but I've found it to be a PITA and not worth the trouble in Windows Mobile. You're better off writing your own simple Logger class that uses a TextWriter to dump info into a text file (for local logging) or calls a webservice function on a remote server. You have total control over what gets written where, and you don't need any Chainsaw nonsense just to read your logs.




回答2:


It's possible to do that. Just write custom appender that checks if server is available and stores data in sqlite if not.

http://karlagius.wordpress.com/2008/01/02/writing-a-custom-appender-for-log4net/




回答3:


SQL CE (Compact Edition) supports replication. You can store the exceptions locally, then synchonize the local datastore with a central server when connected. Some details here.



来源:https://stackoverflow.com/questions/417789/cf-net-exception-and-other-logging

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