log4net:写在共享驱动器上的文件 [英] log4net: Write file located at shared drive

查看:68
本文介绍了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" />


这篇关于log4net:写在共享驱动器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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