Library that supports the use of log4net with WCF
Library that supports the use of log4net with WCF
In web.config perform the following settings:
<configuration>
<configSections>
<!-- Log4Net Configuration -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
...
<log4net>
<root>
<level value="ALL"/>
<appender-ref ref="RollingFileAppender"/>
</root>
<!-- *.TXT FILE CONFIGURATION -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\temp\Logs/.txt"/>
<appendToFile value="true"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<rollingStyle value="Date"/>
<param name="RollingStyle" value="Date"/>
<param name="DatePattern" value="yyyy/MM/dd"/>
<PreserveLogFileNameExtension value="true"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="1024KB"/>
<staticLogFileName value="false"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger %newline%message%newline"/>
</layout>
</appender>
</log4net>
...
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False"/>
<log4net/>
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="log4net" type="Trinity.Wcf.Log4Net.Log4NetBehaviorExtensionElement, Trinity.Wcf.Log4Net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
Even performing the reference to Trinity.Wcf.Log4Net.dll, ensure that it is in the bin folder of the project to run it locally.