I am getting
The process cannot access the file “MyFile.log” because it is being used by another process.
while I am doing this
File.SetAttributes(filename,FileAttributes.Normal)
using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
// Do stuff with log4net log
}
I have read other posts but they all suggest what I am already doing. Any other suggestions?
Thanks.
Try to configure log4net with a minimal lock:
have a look here for better explanation.
Alternatively, try to open the log file with:
or check this project:Tailf
In any case, remove the SetAttributes() part that could not work.
Tailf Project Description
Tailf is a C# implementation of the tail -f command available on unix/linux systems. Differently form other ports it does not lock the file in any way so it works even if other rename the file: this is expecially designed to works well with log4net rolling file appender.