log4net的RollingFileAppender进行和IIS 7.5 [英] log4net RollingFileAppender and IIS 7.5

查看:227
本文介绍了log4net的RollingFileAppender进行和IIS 7.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图与IIS 7.5 / Server 2008 R2上一个RollingFileAppender进行使用log4net的。但是,从我的旧配置IIS 6 / Server 2003的箱似乎没有工作了,我根本就没有看到正在创建的日志文件,这里就是我有设置:

I'm trying to use log4net with a RollingFileAppender on IIS 7.5 / Server 2008 R2. However, the configuration from my old IIS 6 / Server 2003 box doesn't appear to work anymore, I simply don't see any log files being created, here's what I've got setup:

在Web.config文件(在< configSections>

In Web.config (inside <configSections>)

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

在同一个文件(在&LT;结构&gt;

<log4net>
        <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
            </layout>
        </appender>
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="..\\logs\\App" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <param name="StaticLogFileName" value="false" />
      <datePattern value=".yyyyMMdd.lo\g" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date | [%thread] | %-5level | %logger | %message %newline" />
      </layout>
    </appender>
    <logger name="AppLogger" additivity="false">
      <level value="All"/>
      <appender-ref ref="ConsoleAppender"/>
      <appender-ref ref="LogFileAppender"/>
    </logger>
</log4net>

在最后的内部的Global.asax 我有:

protected void Application_Start()
{
    log4net.Config.XmlConfigurator.Configure();
}

这工作Server 2003上,我能做得到的记录器的引用,并呼吁各种方法(调试,错误等)的正常程序。与IIS 7.5 / Server 2008的所有code正确执行(即所有的页面看起来还是ok了),但也有在日志输出目录中没有记录。

This worked on Server 2003 and I can do the normal procedure of obtaining a reference to the logger and calling on the various methods (Debug, Error, etc). With IIS 7.5 / Server 2008 all the code executes properly (ie. all the pages still look ok) but there are no logs in the log output directory.

任何人都见过这个/有一个解决方法吗?

Anyone seen this before / got a workaround?

谢谢!

推荐答案

这是最有可能是的权限问题里的使用者(ASPNET)被写入日志文件没有写的过程中运行权限对该目录您尝试登录。您应该确保这个用户有写权限的文件夹在你的配置。

It's most likely a permissions issue where the user (ASPNET) running under the process that is writing the log files does not have write permissions to that directory you are trying to log in. You should make sure that this user has write permissions to the folder in your config.

这篇关于log4net的RollingFileAppender进行和IIS 7.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆