logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Price, Randall" <randa...@vt.edu>
Subject RE: FileAppender+MinimalLock not working as expected - Correction!
Date Wed, 04 Apr 2007 20:49:27 GMT
Correction!

 

When my WinForms application is running I CAN double-click on the log
file from Windows Explorer and open the log file in Notepad.

 

But when I click my View Log File button on my application, I get the
"process cannot access ... being used by another process" error message.
However process should be the same process making the request to open
the file for reading.

 

Has anyone ever done something like this before?

 

Thanks,

 

Randall Price

Secure Enterprise Technology Initiatives

Microsoft Implementation Group

Virginia Tech Information Technology

1700 Pratt Drive

Blacksburg, VA  24060

Email:      Randall.Price@vt.edu

Phone:     (540) 231-4396

________________________________

From: Price, Randall [mailto:randallp@vt.edu] 
Sent: Wednesday, April 04, 2007 4:38 PM
To: log4net-user@logging.apache.org
Subject: FileAppender+MinimalLock not working as expected

 

Hello,

 

I have an WinForms application in C# that generates data files for a
graphing application.  This application uses log4net to log progress,
information, errors, etc.  I also want this application to be able to
view the log file.  When I try to open the log file I get the following
error message:

 

The process cannot access the file "C:\....\MyApplication.log" because
it is being used by another process.

 

I searched Google and found that I should add the following line to my
configuration file:

 

<lockingModel type="log4net.Appender.FileAppender+MinimalLock\" />

 

Adding this does not seem to allow access to log file.  I expected to be
able to open the log file in Notepad by double-clicking on it but that
also generates the same error.  I want to be able to have my application
open the log file and display the contents in a TextBox but I get the
same error when I try that as well.

 

I am using:

Visual Studio 2005 Professional

Microsoft .NET Framework 2.0

log4net v1.2.10.0

Windows XP Pro w/SP2

 

Here is my configuration file:

 

<?xml version="1.0" encoding="utf-8" ?>

<log4net>

  <appender name="RollingFile"
type="log4net.Appender.RollingFileAppender">

    <file value="MyApplication.log" />

    <appendToFile value="true" />

    <maximumFileSize value="100KB" />

    <maxSizeRollBackups value="2" />

    

    <lockingModel type="log4net.Appender.FileAppender+MinimalLock\" />

 

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date [%thread] %-5level %logger -
%message%newline" />

    </layout>

  </appender>

 

  <root>

    <level value="DEBUG" />

    <appender-ref ref="RollingFile" />

  </root>

</log4net>

 

Am I missing something here?

 

Thanks,

 

Randall Price

Secure Enterprise Technology Initiatives

Microsoft Implementation Group

Virginia Tech Information Technology

1700 Pratt Drive

Blacksburg, VA  24060

Email:      Randall.Price@vt.edu

Phone:     (540) 231-4396

 


Mime
View raw message