简体   繁体   中英

Wcf trace errors to windows service

I have a WCF service running on a windows service. I want that any exception raised in the wcf service will get to the windows service so I can write it to the event log.

I have already made an ErrorHandler class which implements IErrorHandler and IServiceBehavior. And an ErrorHandlerElement which implements BehaviorExtensionElement.

How do I add listeners to the service and receive it at the windows service?

Do you really need the exception to get to the Windows Service to log it? Typically you want to have the global error handler, IErrorHandler, in WCF handle the exception to avoid the host restarting.

In the past, I've use the EnterpriseLibrary Exception Handling and Logging frameworks ( EntLib5 ) to capture and log the exceptions. By using a Event Log Trace Listener (the default) you can log the exception in the IErrorHandler and the exception doesn't need to propagate outside of WCF.

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