I'm writing a WCF web service and I'm wondering if there's an elegant (aspect-oriented) way to use Castle interceptor mechanism for logging exceptions thrown by my web methods? I know about the IInterceptor
inteface, but I could not find any exception information there.
I've seen Castle, AOP and Logging in .NET, but it only covers method's parameters.
Is there a better (WCF or Castle's) mechanism for doing this? BTW I'm using log4net for logging.
UPDATE: I know about WCF's logging facilities, but I was looking more for a general solution, not just in WCF environment.
Thanks in advance.
You should use the build in WCF tracing and logging. Then you can use the WCF Trace Viewer which will piece together logs from service and client so that you can see the full message flow.
http://www.devx.com/dotnet/Article/37389/0/page/6
There is the IErrorHandler interface in WCF:
public interface IErrorHandler
{
bool HandleError(Exception error, MessageFault fault);
void ProvideFault(Exception error, ref MessageFault fault, ref string faultAction);
}
More details here: http://www.extremeexperts.com/Net/Articles/ExceptionHandlingInWCF.aspx