Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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>
Posted

1 solution

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

C#
<lockingmodel type="log4net.Appender.FileAppender+MinimalLock" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900