2

I have the following log4net configuration:

<log4net>
<appender name="Console" type="log4net.Appender.ConsoleAppender">
  <layout type="log4net.Layout.PatternLayout">
    <!-- Pattern to output the caller's file name and line number -->
    <conversionPattern value="%date [%thread] %-5level %ndc - %message%newline" />
  </layout>
</appender>

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
  <file value="C:/logs/mysystem.log" />
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <maximumFileSize value="1024MB" />
  <maxSizeRollBackups value="30" />

  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level - %message%newline" />
  </layout>
</appender>

<root>
  <level value="DEBUG" />
  <appender-ref ref="Console" />
  <appender-ref ref="RollingFile" />
</root>

in the local machine it works fine, but when I deploy the web site to the remote server (IIS 6.0) it does not create the log file despite the fact that the system is running.

The AppPool identity is configured to "Network Service".

Any idea?

4

2 回答 2

2

When the application pool is configured to "Network Service" it does not have sufficient permissions to write to the file system, therefore the log file does not created.

Configure the identity of the app pool to "Local System", it will work fine!

于 2012-08-28T15:11:15.087 回答
0

您可以通过使用机器名称作为原则在文件夹上创建 ACE 来授予对日志文件夹的访问“网络服务”访问权限。将池标识更改为“本地系统”可能会产生不良影响,因此我会避免这种情况。

另一种方法是创建域用户并将此用户添加到机器 IIS_WPG 组。更改池标识以使用此用户。然后,您可以向该用户授予适当的文件夹访问权限。

于 2012-08-28T15:26:17.013 回答