简体   繁体   中英

Logging exceptions from windows service

I've implemented a windows service in C#. What is the best way to register the information regarding exceptions that occurs in windows service? Using EventLoger class is a good idea? Or should I implements my own logger and write exception information to some text file.

Any help is appreciated.

Thank you.

Either use an exception logging/handling library like NBug , or a general purpose logging library like log4net or NLog (you'll need to create custom exception filters with NLog, if you use it).

If you do not want an additional .dll dependency, you're better of using internal System.Diagnostics.Trace & System.Diagnostics.Debug classes.

It depends. The two fundamental questions are: why are you logging the exception, and who will be reviewing the exceptions?

Depending upon the answer to those questions, you might not want to log exceptions at all, or you might want to send an email/sms message to someone to fix things pronto.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM