3

I have used log4net in the past without any trouble, however I am having some issues getting it to log to a file appender. Very simple example.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="DebugFileAppender" type="log4net,Appender.FileAppender">
    <file value="Logfile.log" />
    <appendToFile value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%5p [%d] - %m%n" />
    </layout>
    </appender>
    <root>
      <appender-ref ref="DebugFileAppender" />
    </root>
  </log4net>
</configuration>
Peter
  • 27,590
  • 8
  • 64
  • 84
Youeee
  • 383
  • 3
  • 19

3 Answers3

0

Does the executing account have permission to write to the folder?

Henrik Söderlund
  • 4,286
  • 3
  • 26
  • 26
  • I think so. I opened the permissions on the write directory – Youeee Jan 20 '10 at 16:08
  • If that does not help, try turning on the internal log4net debugging. More info here: http://log4net.sourceforge.net/release/1.2.0.30316/doc/manual/faq.html#internalDebug – Henrik Söderlund Jan 20 '10 at 16:08
0

The comma in the type attribute should be replaced with a period: type="log4net.Appender.FileAppender"

You should be seeing an error similar to

log4net:ERROR Could not create Appender [file] of type [log4net,Appender.FileAppender]. Reported error follows.
...
alexleen
  • 125
  • 1
  • 2
  • 8
0

Try set write permission for the log folders for IIS_IUSRS

kite
  • 1,478
  • 1
  • 15
  • 27