I'm having a problem logging to a text file using log4net dll.
I'm using vs 2012 express on a windows server 2008 r2 standard (64). I have preform the following steps:
- Open a new asp.net web forms
- Install log4net via nuget manager.
in the global.asax file I have this in Application_Start :
log4net.Config.XmlConfigurator.Configure ();
In the web config I have added to the configSections node this line :
< section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
In the web config I have added this section :
<log4net debug="true"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\webSite\extraDownloadServerResources\Logs\ALU\log.txt" /> <appendToFile value="true" /> <rollingStyle value="Composite"/> <datePattern value="yyyyMMdd" /> <maxSizeRollBackups value="5" /> <maximumFileSize value="5MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%n%-5p %d %5rms %-22.22c{1} %-18.18M %n - %m%n" /> </layout> </appender> <root> <level value="DEBUG" /> <appender-ref ref="RollingLogFileAppender" /> </root> </log4net>
In a start up page I have fetch instance of the logger :
private static readonly ILog log = LogManager.GetLogger ( System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType );
In the
Page_Load
I have wrote this line :log.Debug ( "test" );
I have add to the log.txt file security the Dedualt App Pool user with read/write permissions.
I have ended up with nothing in my log file. To test the steps I did I have created a new empty web site and follow these steps one by one. alas (I like this word) this time the log have been written to the file.
Can any one point me to a possible solution ?