GitHub user ssachin3108 opened a pull request: https://github.com/apache/logging-log4net/pull/15
https://issues.apache.org/jira/browse/LOG4NET-552 services installed on production box are separate process and are configured to write log into single log file. Due to this following two issues are happening, During write/append operation some processes are failing with error âUnable to acquire lock on file. The process cannot access the file because it is being used by another processâ. This is because one process acquires lock (thread safe not process safe) for writing into log file and simultaneously another is trying to acquire lock and fails with above error and it just skips writing into log file. During rolling operation, rolled file gets created with less than 1KB size. Thus log entries are lost. Upon investigation we found that, rolling operation is protected by system wide Mutex lock. At the time of rolling, multiple processes may come at the same time for rolling and first process will roll the original file correctly and give a different name to rolled file and re-create blank original file. Now the second process which would have come for rolling will roll the blank original file and overwrite the rolled file created by first process and thus rolled file is losing the data. We locally have fixed above issues by changing latest log4net source code. We have kept locking model as âMinimalLockâ which is current configuration in production. During append operation for acquirelock/releaselock we added system wide mutex so that each process will wait for other process to complete append operation. Thus it will not skip log from being written. During rolling operation we added check whether rolling is already happened by some other process. If yes then skip rolling operation. This will resolve rolling file overwrite by other process issue. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ssachin3108/logging-log4net-1 develop Alternatively you can review and apply these changes as the patch at: https://github.com/apache/logging-log4net/pull/15.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #15 ---- commit bd375a491e8477908b9085d71b6e309340a0e18d Author: spatil <ssachin3...@yahoo.com> Date: 2017-08-18T08:46:30Z https://issues.apache.org/jira/browse/LOG4NET-552 services installed on production box are separate process and are configured to write log into single log file. Due to this following two issues are happening, During write/append operation some processes are failing with error âUnable to acquire lock on file. The process cannot access the file because it is being used by another processâ. This is because one process acquires lock (thread safe not process safe) for writing into log file and simultaneously another is trying to acquire lock and fails with above error and it just skips writing into log file. During rolling operation, rolled file gets created with less than 1KB size. Thus log entries are lost. Upon investigation we found that, rolling operation is protected by system wide Mutex lock. At the time of rolling, multiple processes may come at the same time for rolling and first process will roll the original file correctly and give a different name to rolled file and re-create blank original file. Now the second process which would have come for rolling will roll the blank original file and overwrite the rolled file created by first process and thus rolled file is losing the data. We locally have fixed above issues by changing latest log4net source code. We have kept locking model as âMinimalLockâ which is current configuration in production. During append operation for acquirelock/releaselock we added system wide mutex so that each process will wait for other process to complete append operation. Thus it will not skip log from being written. During rolling operation we added check whether rolling is already happened by some other process. If yes then skip rolling operation. This will resolve rolling file overwrite by other process issue. ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---