--- old+++ new@@ -1,18 +1,21 @@
log4cplus configuration:
-VS2010-Debug/Release-Windows 7 64bit-x64/win32-DLL version/static version-RollingFileAppender++* VS2010+* Debug/Release+* Windows 7 64bit+* x64/win32+* DLL version/static version+* RollingFileAppender
How to reproduce:
+
1. Create exe.
2. Create separate dll and link it to exe.
3. Configure loggers (RollingFileAppender) in dll and exe to use same log file.
4. At this point when file needs to be rolled over, error 13 is returned.
Workaround:
+
1. Use DLL version of log4cplus.
2. Add "log4cplus.appender.<logger name>.UseLockFile=true".
3. At this point RollingFileAppender works as expected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You probably should never have two appenders opening the same file in the first place. You can have a single appender attached to multiple loggers. Doing that, using a single appender for multiple loggers, will fix the problem.
The core of the problem is that the files opened by std::fstream are not opened by the Visual Studio C++ standard library implementation in a way that would allow renaming (or deletion) while there are open handles to the file. This is not easy to fix or work around in any other way than outlined above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Diff:
You probably should never have two appenders opening the same file in the first place. You can have a single appender attached to multiple loggers. Doing that, using a single appender for multiple loggers, will fix the problem.
The core of the problem is that the files opened by
std::fstream
are not opened by the Visual Studio C++ standard library implementation in a way that would allow renaming (or deletion) while there are open handles to the file. This is not easy to fix or work around in any other way than outlined above.