On 10/27/06, Graham (JIRA) <[EMAIL PROTECTED]> wrote:
the second message never gets written to the file. The console error stream
tells me it was due to a locking problem. The exact message as follows;
"log4net:ERROR [RollingFileAppender] Unable to acquire lock on file C:\Tests.XML.
The process cannot access the file 'C:\Tests.XML' because it is being used by another
process."
Are you perhaps simultaneously viewing C:\Tests.XML with some other
program when you get the error? I received similar errors while I was
trying to "follow" a log4net log file with various programs. If this
is the cause of the problem, I've used two approaches to work around
it. When I wrote the program viewing the log file, I was able to
resolve the problem by using file sharing mode of "FileShare.ReadWrite
| FileShare.Delete" when I opened the stream.
I also have modified the RollingFileAppender to catch the exception,
wait a little while then try to open the file again. I'd use this
approach only if I couldn't use the previous approach.
Hope this helps
Mike