Guys
I'm trying using LogCallHandler into Interception like this:
<interception>
<policy name="policyLogCallHandler">
<matchingRule name="LogsMachingRule" type="NamespaceMatchingRule">
<constructor>
<param name="namespaceName" value="NetTcpContracts" />
</constructor>
</matchingRule>
<callHandler type="Microsoft.Practices.EnterpriseLibrary.Logging.PolicyInjection.LogCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="callHandlerLog">
<constructor>
<param name="eventId" value="9002"/>
<param name="logBeforeCall" value="true"/>
<param name="logAfterCall" value="true"/>
<param name="beforeMessage" value="--- begin"/>
<param name="afterMessage" value="--- end"/>
<param name="includeParameters" value="true"/>
<param name="includeCallStack" value="true"/>
<param name="includeCallTime" value="true"/>
<param name="priority" value="1"/>
<param name="order" value="1"/>
</constructor>
</callHandler>
</policy>
</interception>
This configuration throw a exception: "The LogWriter has not been set for the Logger static class. Set it invoking the Logger.SetLogWriter method."
I found solutions for this problem using runtime configuration:
IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
Logger.SetLogWriter(logWriterFactory.Create());
LogEntry entry = new LogEntry();
entry.Message = "I am logging";
Logger.Write(entry)
But, I'm using configuration through config file. How to reproduce this behavior in config file?
Tks!