Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-551

LockRecursionException when using File Appenders

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.7
    • 2.0.8
    • None
    • None

    Description

      I have been getting the following exception on the console:

      log4net:ERROR Exception while logging
      System.Threading.LockRecursionException: Recursive read lock acquisitions not allowed in this mode.
      at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
      at System.Threading.ReaderWriterLockSlim.TryEnterReadLock(TimeoutTracker timeout)
      at System.Threading.ReaderWriterLockSlim.EnterReadLock()
      at log4net.Util.ReaderWriterLock.AcquireReaderLock()
      at log4net.Repository.Hierarchy.Logger.CallAppenders(LoggingEvent loggingEvent)
      at log4net.Repository.Hierarchy.Logger.ForcedLog(Type callerStackBoundaryDeclaringType, Level level, Object message, Exception exception)
      at log4net.Repository.Hierarchy.Logger.Log(Type callerStackBoundaryDeclaringType, Level level, Object message, Exception exception)

      I have a number of different appenders, but this only happens when I am using `log4net.Appender.FileAppender`.

      Using a debugger, I was able to narrow it down to this line (I replaced curly brackets with square brackets because otherwise JIRA interprets them as macros):

      Logger.DebugFormat("[1] Executing SQL: [0][2][0]With parameters: [3]",
      Environment.NewLine, methodName, sql, new ToStringWrapper(parameters));

      My first thought was that ToStringWrapper() was throwing an exception or generating another logging call. But If I put breakpoints at the log call and at the first line of ToStringWrapper.ToString, the exception will show up in the console between those two points.

      Oddly enough, if I "step into" the logging call instead of just "continuing" and letting the breakpoints handle it, no exception happens.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mclefoster Matthew Lefoster
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: