My application uses Log4net to write to the event viewer. Here’s the log4net section of my program’s App.config file:
<log4net>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<applicationName value="CarSystem" />
<logName value="CarSystemLog" />
<threshold value="DEBUG" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="EventLogAppender" />
</root>
</log4net>
Now, these settings were working fine up until about 12:30 pm the day before yesterday. Suddenly, (just when I need to review the messages in the log, of course) it stopped writing to the log file.
The custom event log is in the viewer. I’ve rebooted the machine today, but still nothing new is going into the log. I increased the maximum log size to 10880 KB.
Why isn’t log4net writing to my log file any more?
I went back to the Log4Net documentation and noticed this statement:
Well, I had the XmlConfiguration attribute in my AssemblyInfo.cs and a call to
LogManager.GetLoggerin the code, but it was after a call to start a monitoring object I had added to the constructor of my WPF applicaton’sAppobject. I realized that the logging stopped after I had added this call when I read this statement and reviewed the code.So I moved the call to
LogManager.GetLoggerto be the very first statement in theAppconstructor and the logging began again. Hallelieuia!Thanks for the help and suggestions.