I created custom behavior for use with the WCF service to log all errors in the application log. I made BehaviorExtensionElementfor behavior:
public ErrorLoggingBehaviorExtensionElement : BehaviorExtensionElement
{
public ErrorLoggingBehaviorExtensionElement() { }
}
I am trying to apply this in my configuration as follows:
<extensions>
<behaviorExtensions>
<add name="errorLogging"
type="ErrorLoggingBehaviorExtensionElement, Logging, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=56e8273d901d717f"/>
</behaviorExtensions>
</extensions>
<services>
<service name="TestService" behaviorConfiguration="TestServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="Test_Service.ITestService"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<errorLogging />
</behavior>
</serviceBehaviors>
</behaviors>
NOTE. The "type" attribute in the behavior registration element is actually on the same line in the configuration file to overcome this known problem . Linear breaks have been added for your eyes.
When you try to view the service page, the following application error is generated:
An error occurred while creating the configuration section handler for system.serviceModel / behaviors: no constructor without parameters was specified for this object.
<errorLogging /> , , .