You don't need to reference log4net. dll first.
 
 
 
The configuration and usage are as follows:
 
 
 
Configure in Web. config
 
 
 
<Configuration>
 
<Configsections>
<Section name = "log4net" type = "log4net. config. log4netconfigurationsectionhandler, log4net"/>
 
</Configsections>
 
 
 
<Log4net DEBUG = "false">
<Appender name = "rollinglogfileappender" type = "log4net. appender. rollingfileappender">
<File value = "D:/log/logfile"/>
<Appendtofile value = "true"/>
<Rollingstyle value = "size"/>
<Maxsizerollbackups value = "10"/>
<Maximumfilesize value = "10 MB"/>
<Staticlogfilename value = "true"/>
<Layout type = "log4net. layout. patternlayout">
<Conversionpattern value = "%-5 p % d % 5rms %-22.22c {1} %-18.18 M-% m % N"/>
</Layout>
</Appender>
<Root>
<Level value = "debug"/>
<Appender-ref = "rollinglogfileappender"/>
</Root>
</Log4net>
 
</Configuration>
 
 
 
The next step is to use
 
 
 
Private Static ilog log = logmanager. getlogger (typeof (mylog ));
 
 
 
Mylog is the current class name.
 
 
 
 
 
Then, you can log. Error (MSG), log. debug (MSG), and log. Warn (MSG) as needed.