I want to implement logging function into a class library, which is itself referenced in a webapplication. I tried to add app.config and did everything needed, but its not logging any message, log4net simply does nothing.
Here is my app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="D:\StagingPortal2012\Communicationlogs\TestProjlog4net.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="20MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%-5p %d %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<root>
<appender-ref ref="RollingLogFileAppender" />
<level value="DEBUG"></level>
</root>
</log4net>
<appSettings>
<add key="log4net.Internal.Debug" value="true" />
</appSettings>
</configuration>
And Assembly.Info.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "App.config")]
和Communicator.cs(在这里我使用log4net编写日志)
私有静态只读ILog日志= LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod()。DeclaringType);