logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Blake-Knox <mikebk...@gmail.com>
Subject Re: Log4Net file locking
Date Wed, 23 Nov 2005 13:40:42 GMT
I'd suggest that you change the program that's displaying the log file so
that it uses FileAccess.ReadWrite AND FileShare.ReadWrite when opening the
file. Otherwise, you won't be able to open the file as it already has a
writer.

This generally works fine with the RollingFileAppender but note that if you
use RollingFileAppender options that cause the file to be renamed, the
RollingFileAppender is automatically entered in the "can't rename the file
because someone else has it open lottery". (If you're using .NET 2.0,
there's a chance that adding Delete to FileShare in your program will
resolve this). Alternatively, using a FileSystemWatcher in your reading
program so that the file isn't open all the time might help.

Mike

On 11/22/05, Sankalp <sankalp@proteans.com> wrote:
>
> Hi,
> We wish to port our .NET windows application logging to Log4Net but are
> facing a
> problem. Our application dispays the log file in a rich text box so that
> the
> user can debug himself what all is happening in the application. We plan
> to user
> RollingFileAppender so that logs can remain for certain period pf time.
> However, there is some problem here. When we try reading the log file and
> display it in the rich text box, then it says that the file is in use and
> cant
> be accessed. Log4Net is putting a lock on the file. I tried changing the
> locking
> level to Minimal Lock using a file Appender but even that didnt help as as
> soon
> as the log is written, we simultaneoulsy display it in the rich text box.
> Pointers any one????
>
>


--
Mike Blake-Knox

Mime
View raw message