log4net:写在共享驱动器上的文件

问题描述:

我有两个记录器来记录错误。一个记录器将日志写入一个文件,该文件被放入共享驱动器。另一个记录器发送错误的电子邮件。



电子邮件记录器工作正常。但是日志文件并不反映每个错误日志。



我认为问题是因为它在许多用户之间共享。所以记录器可能会锁定文件而不允许其他应用程序记录器写入。



这是真的吗?如果没有那么请指导我解决这个问题。



这里是我的appender,它将日志写入共享文件



I have two loggers to log errors. One logger writes log into a file which is put in to a shared drive. The other logger shoots email of error.

Email logger works very fine. But the log file doesnt reflect every error log.

I think the problem is because its being shared between many users. So the logger may lock the file and dont allow other apps loggers to write.

IS this true? If not then please guide me to solve this problem.

here is my appender which writes log to the shared file

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="\\server03\logfiles\abc\log.txt"/>
      <appendToFile value="true"/>
      <rollingStyle value="Size"/>
      <maxSizeRollBackups value="10"/>
      <maximumFileSize value="10MB"/>
      <staticLogFileName value="true"/>
      <layout type="CustomLog4NetPattern.CustomPatternLayout">
        <conversionPattern value="%newline%level-%date%newline%logger%newline[User]=%identity%newline[Machine]=%property{log4net:HostName}%newline[User Machine]=%UserMachine%newline[User IP]= %aspnet-request{REMOTE_ADDR}%newline%message%newline%exception%newline===========" />
      </layout>
    </appender>

Markand,您可能想尝试使用最小值锁定模型。



Markand, you may want to try using the minimal locking model.

<lockingmodel type="log4net.Appender.FileAppender+MinimalLock" />