How can I get the ValidationFault Details in the log?

Topics: Exception Handling Application Block, Logging Application Block, Validation Application Block
Dec 11, 2010 at 8:15 AM

I'm using WCF Exception Shielding to catch exceptions in the service and log them.  I'm also using WCF Validation.  I've managed to configure it such that FaultException<ValidationFault>'s just get logged and returned to the caller whereas other service Exceptions get logged and turned into FaultException<ServiceFault>.  I'd like to record the actual validation faults in the log.   At the moment, all I get is this:

andlingInstanceID: 2aa6c907-5069-41d7-a331-0572ea63fdfa  An exception of type 'System.ServiceModel.FaultException`1[[Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationFault, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' occurred and was caught.  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  12/11/2010 09:03:12  Type : System.ServiceModel.FaultException`1[[Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationFault, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  Message : The creator of this fault did not specify a Reason.  Source : Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF  Help link :   Detail : Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationFault  Action :   Code : System.ServiceModel.FaultCode  Reason : The creator of this fault did not specify a Reason.  Data : System.Collections.ListDictionaryInternal  TargetSite : System.Object BeforeCall(System.String, Sy

Is there a way of doing this? 

Dec 13, 2010 at 10:16 AM

We'll look into this and keep you posted.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 14, 2010 at 7:59 AM

Do you need to configure the logging on the service?  Because the validation errors can be accessed if you catch the FaultException<ValidationFault> in the client and iterate through its .Detail.Details property.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 7, 2011 at 1:21 PM

I have exactly the same issue as sgarratt:  WCF, Exception Shielding, VAB, logging configured to handle FaultException<ValidationFault> with the XmlTraceListener.

I can't get the ValidationFault details to show up in the log.  Is there some kind of mapping you can do like for the text trace listener?

Jan 10, 2011 at 6:48 AM
Edited Jan 10, 2011 at 6:49 AM

Unfortunately, there's no mapping which would solve this.  The only way I could think of right now is to create a custom exception handler which would enable you to log the contents of the Detail.Details property.

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com