log4net dll没有创建日志文件

时间:2015-04-27 07:03:21

标签: c# asp.net log4net

我的代码是,

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>

然后是webconfig标签]

<log4net debug="true">
<appender name="FileAppender" type="log4net.Appender.FileAppender">
  <param name="File" value="c:\\ PeejayImpex.log"/>
  <!-- Example using environment variables in params -->
  <!-- <param name="File" value="${TMP}\\ApplicationKit.log" /> -->
  <param name="AppendToFile" value="true"/>
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d [%t] %-2p %c [%x] - %m%n"/>
  </layout>
</appender>

<root>
  <level value="ALL"/>
  <appender-ref ref="FileAppender"/>
</root>

它完成没有错误

然后在全局文件中

 void Application_Start(object sender, EventArgs e) 
{
    // Code that runs on application startup

    log4net.Config.XmlConfigurator.Configure();
}

之后我在pageload中写道..

protected void Page_Load(object sender, EventArgs e)
{
    if (log.IsErrorEnabled)
    {
        log.Info("Hello Nine Thanks for use Log4Net,This is info message");
        log.Debug("Hello Nine Thanks for use Log4Net,This is Debug message");
        log.Error("Hello Nine Thanks for use Log4Net,This is Error message");
        log.Warn("Hello Nine Thanks for use Log4Net,This is Warn message");
        log.Fatal("Hello Nine Thanks for use Log4Net,This is Fatal message");
        log.Debug("Did it again!");
    }
    }

我第一次使用它时idont知道什么是错的请帮助我,因为没有创建日志文件时没有错误,所以确实缺少了一些东西。 :)

0 个答案:

没有答案