How to log message in 'messageTemplate' field in validation section of web.config

Apr 30, 2012 at 9:56 AM

Hi,

I am using Enterprise Library 5.0 and trying to use Validation block. In case of validation fails the log message displayed is something like bellow message:

" Message : Parameter validation failed "

I want to log message in 'message template' field in web.config file.

Please assist me.

Bellow is given 'validation' section in web.config

 

<validation>
<type name="MusicStore.Classical" defaultRuleset="Classical RuleSet"
assemblyName="MusicStore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<ruleset name="Classical RuleSet">
<properties>
<property name="Name">
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
messageTemplate="Album Name can not be empty"
name="Not Null Validator" />
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
upperBound="20" lowerBound="10" lowerBoundType="Inclusive" upperBoundType="Ignore"
messageTemplate="Album name should be at least one character long"
name="String Length Validator" />
</property>
</properties>
</ruleset>
</type>
</validation>