So for some reason our logger has stopped logging and I am at a complete loss as to why.
What I’m using in my project is the following:
The log4net configuration:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="UdpAppender" />
<appender-ref ref="RollingFile" />
</root>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<remoteAddress value="127.0.0.1" />
<remotePort value="8180" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="Logs/DA.RA.log"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<appendToFile value="true"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="10MB"/>
<rollingStyle value="Size"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level %date %logger - %message%newline"/>
</layout>
</appender>
</log4net>
In my web.config I have the following line:
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=a3d255455d3dcb36"
requirePermission="false"/>
In my global.asax I have the following line in the application_start method:
string filename = Server.MapPath( @"~\XML\log4net.xml" );
log4net.Config.XmlConfigurator.ConfigureAndWatch( new System.IO.FileInfo( filename ) );
and when I call the logger in any of my pages I use:
private static readonly ILog logger = LogManager.GetLogger(typeof(ReportParameters));
I have tried many different things I found online. These include:
adding the following line to the assembly in my project
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
I tried:
[assembly: log4net.Config.XmlConfigurator()]
I’ve upgraded the version of my log4net.dll from 1.2.10.0 to 1.2.11.0.
I tried adding the log4net appenders to the web.config file instead of in it’s own file, and I still get nothing out of the logging.
Try opening internal debugging of log4net and check or share the result:
Note: I made a sample app and used your same log4net.xml file and ConfigureAndWatch statement and it worked without a problem. I think you are having a filename path resolution problem or permission to write problem. Create log folder If you didn’t.
You need to add to web.config