Log4net
  1. Log4net
  2. LOG4NET-156

Probable I/O race condition detected while copying memory.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.10
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      Windows XP Professional

      Description

      Currently we are facing some issues with the log4net configuration in our project. I am looking for help on this.

      We are getting the following error in the log4net log file:

      Error: Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.]

      We are using the rollinglogfileAppender with the rolling style as "Date" and the locking model as "log4net.Appender.FileAppender+MinimalLock".

      When nearly 250 users in our application tries to write to the log file it is coming with the above error message.

      Any help is greatly appreciated.

        Activity

        Hide
        Ron Grabowski added a comment -

        The RollingFileAppender/MinimalLock combination most likely won't work with 250+ users....RollingFileAppender/MinimalLock isn't a database! If you must use a RollingFileAppender use a MutextLock instead.

        Show
        Ron Grabowski added a comment - The RollingFileAppender/MinimalLock combination most likely won't work with 250+ users....RollingFileAppender/MinimalLock isn't a database! If you must use a RollingFileAppender use a MutextLock instead.
        Hide
        Ron Grabowski added a comment -

        Use your browser to navigate to this page:

        http://www.google.com/

        type the following text into the search box that appears:

        log4net mailing lists

        then press the button that says:

        I'm Feeling Lucky

        You can also visit the log4net home page to find out how to subscribe to the lists.

        Show
        Ron Grabowski added a comment - Use your browser to navigate to this page: http://www.google.com/ type the following text into the search box that appears: log4net mailing lists then press the button that says: I'm Feeling Lucky You can also visit the log4net home page to find out how to subscribe to the lists.
        Hide
        siva added a comment -

        Could you please tell me how to take this discussion to mailing lists?

        Thanks
        Siva

        Show
        siva added a comment - Could you please tell me how to take this discussion to mailing lists? Thanks Siva
        Hide
        Ron Grabowski added a comment -

        This doesn't look like log4net bug so I'm recommending again that you take this discussion to one of the mailing lists. More people monitor the lists so you might get a faster response from there.

        The MinimalLock is very slow compared to the default ExclusiveLock. Its not designed for what you're using it for. Do you have multiple instances of your program trying to write to the same file? With 250 users it sounds like the AdoNetAppender would be a better choice. log4net isn't a database server. Have you tried using the MutexLock that was posted to the log4net-users list a few months ago? That allows multiple processes to write to the same file while still being performant.

        I'd recommend against using the RollingFileAppender and the MinimalLock in all but the most basic scenarios (i.e. for single user / single threaded apps its fine).

        I'm eventually going to mark this ticket as Invalid.

        Show
        Ron Grabowski added a comment - This doesn't look like log4net bug so I'm recommending again that you take this discussion to one of the mailing lists. More people monitor the lists so you might get a faster response from there. The MinimalLock is very slow compared to the default ExclusiveLock. Its not designed for what you're using it for. Do you have multiple instances of your program trying to write to the same file? With 250 users it sounds like the AdoNetAppender would be a better choice. log4net isn't a database server. Have you tried using the MutexLock that was posted to the log4net-users list a few months ago? That allows multiple processes to write to the same file while still being performant. I'd recommend against using the RollingFileAppender and the MinimalLock in all but the most basic scenarios (i.e. for single user / single threaded apps its fine). I'm eventually going to mark this ticket as Invalid.
        Hide
        siva added a comment -

        Hi Ron,

        Thanks for your reply.
        Please see the Log4net setting for my application
        <root>
        <level value="INFO"/>
        <appender-ref ref="RollingLogger" />
        <appender-ref ref="EventLogAppender" />
        </root>

        <appender name="RollingLogger"
        type="log4net.Appender.RollingFileAppender">
        <param name="File"
        value="E:\Pages\Health\PrePricingBatch\Logs\" />
        <StaticLogFileName value="false" />
        <lockingModel
        type="log4net.Appender.FileAppender+MinimalLock" />
        <appendToFile value="true" />
        <maxSizeRollBackups value="10" />
        <rollingStyle value="Date" />
        <datePattern value="yyyy_MM_dd\.\l\o\g" />
        <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%d %logger[%t]
        %-5level - %m%n" />
        </layout>
        </appender>

        Since there are many users accessing the application and want to write
        the information for each process we used the locking model
        "MinimalLock".

        Thanks,
        Siva

        Show
        siva added a comment - Hi Ron, Thanks for your reply. Please see the Log4net setting for my application <root> <level value="INFO"/> <appender-ref ref="RollingLogger" /> <appender-ref ref="EventLogAppender" /> </root> <appender name="RollingLogger" type="log4net.Appender.RollingFileAppender"> <param name="File" value="E:\Pages\Health\PrePricingBatch\Logs\" /> <StaticLogFileName value="false" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <appendToFile value="true" /> <maxSizeRollBackups value="10" /> <rollingStyle value="Date" /> <datePattern value="yyyy_MM_dd\.\l\o\g" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d %logger [%t] %-5level - %m%n" /> </layout> </appender> Since there are many users accessing the application and want to write the information for each process we used the locking model "MinimalLock". Thanks, Siva
        Hide
        Ron Grabowski added a comment -

        The mailing lists are much better places to ask for general help about log4net.

        What is your Date pattern for the rolling?

        MinimalLock is very slow. Why aren't you using the default ExclusiveLock?

        Show
        Ron Grabowski added a comment - The mailing lists are much better places to ask for general help about log4net. What is your Date pattern for the rolling? MinimalLock is very slow. Why aren't you using the default ExclusiveLock?
        Hide
        siva added a comment -

        Any help on this will be greatly appreciated.

        Thanks,
        Siva

        Show
        siva added a comment - Any help on this will be greatly appreciated. Thanks, Siva

          People

          • Assignee:
            Ron Grabowski
            Reporter:
            siva
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development