Log4net
  1. Log4net
  2. LOG4NET-164

using a named mutex for file appenders

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.11
    • Component/s: Appenders
    • Labels:
      None

      Description

      About logging to the same file from 2 or more instances of an application.
      As opposed to a minimallock which makes it still possible for 2 application instances to interfere. Why not use a named mutex so that the logging will wait for the lock to be released from another instance.

        Activity

        Hide
        Ron Grabowski added a comment -

        Yep...someone already posted some code they're using:

        http://www.mail-archive.com/log4net-user@logging.apache.org/msg04116.html

        I think we need to get them to upload the patch to JIRA and mark it as being ok to include in the code base or else we'll have to re-implement it.

        Show
        Ron Grabowski added a comment - Yep...someone already posted some code they're using: http://www.mail-archive.com/log4net-user@logging.apache.org/msg04116.html I think we need to get them to upload the patch to JIRA and mark it as being ok to include in the code base or else we'll have to re-implement it.
        Hide
        Ron Grabowski added a comment -

        Added ProcessLock inner class alongside ExclusiveLock and MinimalLock that uses a Mutex to allows multiple processes to correctly lock to the same file without having to open and close the file for each write.

        ProcessLock name may need to change...MutexLock, InterProcessLock?

        Show
        Ron Grabowski added a comment - Added ProcessLock inner class alongside ExclusiveLock and MinimalLock that uses a Mutex to allows multiple processes to correctly lock to the same file without having to open and close the file for each write. ProcessLock name may need to change...MutexLock, InterProcessLock?
        Hide
        Eike-Peter Falk added a comment -

        I find InterProcessLock better than MutexLock, cause Mutex is a rather general term.
        How about SystemWideLock? GlobalLock?

        Show
        Eike-Peter Falk added a comment - I find InterProcessLock better than MutexLock, cause Mutex is a rather general term. How about SystemWideLock? GlobalLock?
        Hide
        Stefan Bodewig added a comment -

        You should probably move the Mutex-releasing code of CloseFile into a finally block so it will be performed even if CloseStream fails.

        Other than deciding on the name (which I'm not really good at) is there anything else that needs to b done in order to resolve this issue?

        Show
        Stefan Bodewig added a comment - You should probably move the Mutex-releasing code of CloseFile into a finally block so it will be performed even if CloseStream fails. Other than deciding on the name (which I'm not really good at) is there anything else that needs to b done in order to resolve this issue?
        Hide
        Stefan Bodewig added a comment -

        Note the patch has introduced an issue with MinimalLock that I've now resolved (LOG4NET-311).

        The third parameter of the create stream method that the patch adds is never used by anything - has this been intended to be used as forth paramter to the FileStream constructor?

        Show
        Stefan Bodewig added a comment - Note the patch has introduced an issue with MinimalLock that I've now resolved ( LOG4NET-311 ). The third parameter of the create stream method that the patch adds is never used by anything - has this been intended to be used as forth paramter to the FileStream constructor?
        Hide
        Stefan Bodewig added a comment -

        I've added simple tests in svn revision 1166079 and made them pass. Obviously the third arg of CreateStream was expected to be used in the FileStream constructor.

        So now the main remaining issue is naming (and documentation).

        Show
        Stefan Bodewig added a comment - I've added simple tests in svn revision 1166079 and made them pass. Obviously the third arg of CreateStream was expected to be used in the FileStream constructor. So now the main remaining issue is naming (and documentation).
        Hide
        Ron Grabowski added a comment -

        I like the name InterProcessLock

        Show
        Ron Grabowski added a comment - I like the name InterProcessLock
        Hide
        Stefan Bodewig added a comment -

        InterProcessLock it is.

        Documentation added with svn revision 1173083

        Show
        Stefan Bodewig added a comment - InterProcessLock it is. Documentation added with svn revision 1173083

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 24h
              24h
              Remaining:
              Remaining Estimate - 24h
              24h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development