I am trying to use log4net . When I launch the application, it creates a log file, but no matter how many times I call Log.Info("Application Started"); It stays empty. I examined the first two pages that google returns, and my code seems to follow all the examples.
the code:
[assembly: XmlConfigurator(Watch = true)] namespace Generator { public class Run { private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public List<BILL_RUN> PerformBillRun() { XmlConfigurator.Configure(); Log.Info("Application Started"); var enabled = Log.IsInfoEnabled; //This is true } } }
app.config
<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net> <appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="log-files.txt" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <root> <level value="All" /> <appender-ref ref="FileAppender" /> </root> </log4net>
Any guidance on what might be wrong?
m.edmondson
source share