Tuesday, October 5, 2010

configure log4Net

Web.Config:-


under configsection

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>

<log4net>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="logs\\error_04112009.log" />
<param name="AppendToFile" value="true"/>
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} - %m%n" />
</layout>
</appender>
<logger name="File">
<level value="All" />
<appender-ref ref="LogFileAppender" />
</logger>
</log4net>


Global.asax:-

void Application_Start(object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
}