From log4net-user-returnloganbryant@example.org Wed Apr 04 20:31:32 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 60571 invoked from network); 4 Apr 2007 20:31:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2007 20:31:32 -0000 Received: (qmail 13156 invoked by uid 500); 4 Apr 2007 20:31:35 -0000 Delivered-To: loganbryant@example.org Received: (qmail 13113 invoked by uid 500); 4 Apr 2007 20:31:34 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 13098 invoked by uid 99); 4 Apr 2007 20:31:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:31:34 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of loganbryant@example.org designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO talk.nabble.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:31:26 -0700 Received: from [83.161.120.155] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HZC8H-0007FR-EK for loganbryant@example.org; Wed, 04 Apr 2007 13:31:05 -0700 Message-ID: <loganbryant@example.org> Date: Wed, 4 Apr 2007 13:31:05 -0700 (PDT) From: Frogg <loganbryant@example.org> To: loganbryant@example.org Subject: FileAppender ExclusiveLock workaround (Not MinimalLock) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: loganbryant@example.org X-Virus-Checked: Checked by ClamAV on apache.org Hello, We used to use a really old version of log4net (1.2.03) but have since upgraded to 1.2.10. With the old log4net we created a custom FileAppender so that different application domains could log to the same file (this was before the days of MinimalLock). Basically, what we did was to override the OpenFile method to open the file stream in share mode, thus allowing many processes to write to the file at the same time. This is how the code looked that worked with the old log4net dll: ==================Code c#========================= protected override void OpenFile(string rawFileName, bool append) { lock(this) { // Release any current configuration and prepare for new. Reset(); // Make THIS loganbryant@example.org. LogLog.Debug( string.Format( "CustomFileAppender: Opening file for SHARED writing[{0}] append [{1}] ",fileName, append ) ); // Create the directory if needed Directory.CreateDirectory((new FileInfo(fileName)).DirectoryName); // Open the file to allow reading and writing WHILE OPEN FileStream fs = new FileStream(fileName,FileMode.Append,FileAccess.Write,FileShare.ReadWrite); // and store for use in the base class SetQWForFiles(new StreamWriter(fs)); // save the name and append settings base.File = fileName; base.AppendToFile = append; // and write out any header details WriteHeader(); } ==============End Code====================== When we upgraded to the 1.2.10 this code no longer worked. I tried using MinimalLock instead of the above code but that has the unfortunate side effects of being very slow(Lock, Unlock, Lock, Unlock, etc) and allowing some other process to maintain an exclusive lock on the file (no matter how short of time), someone other than the logger (for example, someone is viewing the log file, the application is not able to log events because that person viewing got a writer lock). I would like to be able to redo the code above to work with 1.2.10 but my attempts thus far have been unsuccessfull, if anyone has any ideas that may put me on the right track I would be greatly appreciative. Thanks, -- View this message in context: http://www.nabble.com/FileAppender-ExclusiveLock-workaround-%28Not-MinimalLock%29-tf3528119.html#a9845029 Sent from the Log4net - Users mailing list loganbryant@example.org. From log4net-user-returnloganbryant@example.org Wed Apr 04 20:38:19 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 62492 invoked from network); 4 Apr 2007 20:38:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2007 20:38:18 -0000 Received: (qmail 23218 invoked by uid 500); 4 Apr 2007 20:38:23 -0000 Delivered-To: loganbryant@example.org Received: (qmail 23193 invoked by uid 500); 4 Apr 2007 20:38:23 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 23182 invoked by uid 99); 4 Apr 2007 20:38:23 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:38:23 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of loganbryant@example.org designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO rivendell.cc.vt.edu) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:38:14 -0700 Received: from elessar.cc.vt.edu ([83.161.120.155]) by rivendell.cc.vt.edu with Microsoft SMTPSVC(5.0.2195.6713); Wed, 4 Apr 2007 16:37:53 -0400 X-MIMEOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C776F9.1E5FABD7" Subject: FileAppender+MinimalLock not working as expected Date: Wed, 4 Apr 2007 16:37:52 -0400 Message-ID: <loganbryant@example.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: FileAppender+MinimalLock not working as expected Thread-index: Acd2+R4yaYKVafluQlS6hGSJMU8AqQ== From: "Price, Randall" <loganbryant@example.org> To: <loganbryant@example.org> X-OriginalArrivalTime: 04 Apr 2007 20:37:53.0546 (UTC) FILETIME=[1E9676A0:01C776F9] X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C776F9.1E5FABD7 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, =20 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: =20 The process cannot access the file "C:\....\MyApplication.log" because it is being used by another process. =20 I searched Google and found that I should add the following line to my configuration file: =20 <lockingModel type=3D"log4net.Appender.FileAppender+MinimalLock\" /> =20 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. =20 I am using: Visual Studio 2005 Professional Microsoft .NET Framework 2.0 log4net v83.161.120.155 Windows XP Pro w/SP2 =20 Here is my configuration file: =20 <?xml version=3D"1.0" encoding=3D"utf-8" ?> <log4net> <appender name=3D"RollingFile" type=3D"log4net.Appender.RollingFileAppender"> <file value=3D"MyApplication.log" /> <appendToFile value=3D"true" /> <maximumFileSize value=3D"100KB" /> <maxSizeRollBackups value=3D"2" /> =20 <lockingModel type=3D"log4net.Appender.FileAppender+MinimalLock\" /> =20 <layout type=3D"log4net.Layout.PatternLayout"> <conversionPattern value=3D"%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> =20 <root> <level value=3D"DEBUG" /> <appender-ref ref=3D"RollingFile" /> </root> </log4net> =20 Am I missing something here? =20 Thanks, =20 Randall Price Secure Enterprise Technology Initiatives Microsoft Implementation Group Virginia Tech Information Technology 1700 Pratt Drive Blacksburg, VA 24060 Email: loganbryant@example.org Phone: (464)853-2585 =20 ------_=_NextPart_001_01C776F9.1E5FABD7 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" = xmlns=3D"http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3DContent-Type content=3D"text/html; = charset=3Dus-ascii"> <meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)"> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"Street"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"address"/> <!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:Arial; color:windowtext;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </style> </head> <body lang=3DEN-US link=3Dblue vlink=3Dpurple> <div class=3DSection1> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Hello,<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I have an WinForms application in C# that generates = data files for a graphing application.&nbsp; This application uses log4net to = log progress, information, errors, etc.&nbsp; I also want this application = to be able to view the log file.&nbsp; When I try to open the log file I get = the following error message:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>The process cannot access the file = &#8220;C:\....\MyApplication.log&#8221; because it is being used by another = process.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I searched Google and found that I should add the = following line to my configuration file:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;lockingModel type=3D&quot;log4net.Appender.FileAppender+MinimalLock\&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Adding this does not seem to allow access to log = file.&nbsp; I expected to be able to open the log file in Notepad by double-clicking = on it but that also generates the same error.&nbsp; 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.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I am using:<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Visual Studio 2005 = Professional<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Microsoft .NET Framework = 2.0<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>log4net = v83.161.120.155<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Windows XP Pro = w/SP2<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo= nt></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Here is my configuration = file:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;?xml version=3D&quot;1.0&quot; = encoding=3D&quot;utf-8&quot; ?&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;log4net&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;appender name=3D&quot;RollingFile&quot; type=3D&quot;log4net.Appender.RollingFileAppender&quot;&gt;<o:p></o:p></s= pan></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;file = value=3D&quot;MyApplication.log&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;appendToFile = value=3D&quot;true&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;maximumFileSize = value=3D&quot;100KB&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;maxSizeRollBackups = value=3D&quot;2&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;lockingModel type=3D&quot;log4net.Appender.FileAppender+MinimalLock\&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;layout type=3D&quot;log4net.Layout.PatternLayout&quot;&gt;<o:p></o:p></span></fo= nt></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;conversionPattern value=3D&quot;%date [%thread] %-5level %logger - %message%newline&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; = &lt;/layout&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;/appender&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;root&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;level = value=3D&quot;DEBUG&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;appender-ref ref=3D&quot;RollingFile&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;/root&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;/log4net&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Am I missing something = here?<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Thanks,<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><b><font size=3D3 = color=3D"#990000" face=3DArial><span = style=3D'font-size:12.0pt;font-family:Arial;color:#990000; font-weight:bold'>Randall Price</span></font><font = color=3D"#990000"><span style=3D'color:#990000'><o:p></o:p></span></font></b></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Secure Enterprise Technology = Initiatives<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Microsoft Implementation = Group</span></font><o:p></o:p></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Virginia Tech Information = Technology</span></font><o:p></o:p></p> <p class=3DMsoNormal><st1:Street w:st=3D"on"><st1:address style=3D"BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: = url(res://ietag.dll/#34/#1001); BACKGROUND-REPEAT: repeat-x" tabIndex=3D"0" w:st=3D"on"><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>1700 Pratt = Drive</span></font></st1:address></st1:Street><o:p></o:p></p> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Blacksburg, VA&nbsp; = 24060</span></font><o:p></o:p></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=3D"mailto:loganbryant@example.org">loganbryant@example.org</a></span></fon= t><o:p></o:p></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Phone:&nbsp;&nbsp;&nbsp;&nbsp; (540) = 231-4396</span></font><o:p></o:p></p> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'><o:p>&nbsp;</o:p></span></font></p> </div> </body> </html> ------_=_NextPart_001_01C776F9.1E5FABD7-- From log4net-user-returnloganbryant@example.org Wed Apr 04 20:49:52 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 65380 invoked from network); 4 Apr 2007 20:49:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2007 20:49:52 -0000 Received: (qmail 46414 invoked by uid 500); 4 Apr 2007 20:49:57 -0000 Delivered-To: loganbryant@example.org Received: (qmail 46396 invoked by uid 500); 4 Apr 2007 20:49:57 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 46385 invoked by uid 99); 4 Apr 2007 20:49:57 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:49:57 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of loganbryant@example.org designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO rivendell.cc.vt.edu) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 13:49:49 -0700 Received: from elessar.cc.vt.edu ([83.161.120.155]) by rivendell.cc.vt.edu with Microsoft SMTPSVC(5.0.2195.6713); Wed, 4 Apr 2007 16:49:28 -0400 X-MIMEOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C776FA.BC6D824A" Subject: RE: FileAppender+MinimalLock not working as expected - Correction! Date: Wed, 4 Apr 2007 16:49:27 -0400 Message-ID: <loganbryant@example.org> In-reply-to: <loganbryant@example.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: FileAppender+MinimalLock not working as expected - Correction! Thread-index: Acd2+R4yaYKVafluQlS6hGSJMU8AqQAAUuHg References: <loganbryant@example.org> From: "Price, Randall" <loganbryant@example.org> To: "Log4NET User" <loganbryant@example.org> X-OriginalArrivalTime: 04 Apr 2007 20:49:28.0421 (UTC) FILETIME=[BCC3F950:01C776FA] X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C776FA.BC6D824A Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Correction! =20 When my WinForms application is running I CAN double-click on the log file from Windows Explorer and open the log file in Notepad. =20 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. =20 Has anyone ever done something like this before? =20 Thanks, =20 Randall Price Secure Enterprise Technology Initiatives Microsoft Implementation Group Virginia Tech Information Technology 1700 Pratt Drive Blacksburg, VA 24060 Email: loganbryant@example.org Phone: (464)853-2585 ________________________________ From: Price, Randall [mailto:loganbryant@example.org]=20 Sent: Wednesday, April 04, 2007 4:38 PM To: loganbryant@example.org Subject: FileAppender+MinimalLock not working as expected =20 Hello, =20 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: =20 The process cannot access the file "C:\....\MyApplication.log" because it is being used by another process. =20 I searched Google and found that I should add the following line to my configuration file: =20 <lockingModel type=3D"log4net.Appender.FileAppender+MinimalLock\" /> =20 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. =20 I am using: Visual Studio 2005 Professional Microsoft .NET Framework 2.0 log4net v83.161.120.155 Windows XP Pro w/SP2 =20 Here is my configuration file: =20 <?xml version=3D"1.0" encoding=3D"utf-8" ?> <log4net> <appender name=3D"RollingFile" type=3D"log4net.Appender.RollingFileAppender"> <file value=3D"MyApplication.log" /> <appendToFile value=3D"true" /> <maximumFileSize value=3D"100KB" /> <maxSizeRollBackups value=3D"2" /> =20 <lockingModel type=3D"log4net.Appender.FileAppender+MinimalLock\" /> =20 <layout type=3D"log4net.Layout.PatternLayout"> <conversionPattern value=3D"%date [%thread] %-5level %logger - %message%newline" /> </layout> </appender> =20 <root> <level value=3D"DEBUG" /> <appender-ref ref=3D"RollingFile" /> </root> </log4net> =20 Am I missing something here? =20 Thanks, =20 Randall Price Secure Enterprise Technology Initiatives Microsoft Implementation Group Virginia Tech Information Technology 1700 Pratt Drive Blacksburg, VA 24060 Email: loganbryant@example.org Phone: (464)853-2585 =20 ------_=_NextPart_001_01C776FA.BC6D824A Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" = xmlns=3D"http://www.w3.org/TR/REC-html40"> <head> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:SmartTagType namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" = name=3D"PostalCode"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"State"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"Street"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"address"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"City"/> <o:SmartTagType = namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" name=3D"place"/> <!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <style> <!-- /* Font Definitions */ @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal; font-family:Arial; color:windowtext;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:Arial; color:navy;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </style> </head> <body lang=3DEN-US link=3Dblue vlink=3Dpurple> <div class=3DSection1> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Correction!<o:p></o:p></span></font>= </p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>When my WinForms application is = running I CAN double-click on the log file from Windows Explorer and open the log file = in Notepad.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>But when I click my View Log File = button on my application, I get the &#8220;process cannot access &#8230; being = used by another process&#8221; error message.&nbsp; However process should be = the same process making the request to open the file for = reading.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Has anyone ever done something like = this before?<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Thanks,<o:p></o:p></span></font></p>= <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>&nbsp;<o:p></o:p></span></font></p> <div> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><b><font size=3D3 = color=3D"#990000" face=3DArial><span = style=3D'font-size:12.0pt;font-family:Arial;color:#990000; font-weight:bold'>Randall Price</span></font><font = color=3D"#990000"><span style=3D'color:#990000'><o:p></o:p></span></font></b></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Secure Enterprise Technology = Initiatives<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Microsoft Implementation = Group</span></font><font color=3Dnavy><span style=3D'color:navy'><o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Virginia Tech Information = Technology</span></font><font color=3Dnavy><span style=3D'color:navy'><o:p></o:p></span></font></p> <p class=3DMsoNormal><st1:Street w:st=3D"on"><st1:address style=3D"BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: = url(res://ietag.dll/#34/#1001); BACKGROUND-REPEAT: repeat-x" tabIndex=3D"0" w:st=3D"on"><font size=3D2 color=3Dnavy = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial;color:navy'>1700 Pratt = Drive</span></font></st1:address></st1:Street><font color=3Dnavy><span style=3D'color:navy'><o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><font size=3D2 = color=3Dnavy face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Blacksburg, VA&nbsp; 24060</span></font><font color=3Dnavy><span = style=3D'color:navy'><o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= <a href=3D"mailto:loganbryant@example.org">loganbryant@example.org</a></span></fon= t><font color=3Dnavy><span style=3D'color:navy'><o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Phone:&nbsp;&nbsp;&nbsp;&nbsp; = (464)853-2585</span></font><o:p></o:p></p> </div> <div> <div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font = size=3D3 face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> <hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1> </span></font></div> <p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span = style=3D'font-size:10.0pt; font-family:Tahoma;font-weight:bold'>From:</span></font></b><font = size=3D2 face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> = Price, Randall [mailto:loganbryant@example.org] <br> <b><span style=3D'font-weight:bold'>Sent:</span></b> Wednesday, April = 04, 2007 4:38 PM<br> <b><span style=3D'font-weight:bold'>To:</span></b> loganbryant@example.org<br> <b><span style=3D'font-weight:bold'>Subject:</span></b> = FileAppender+MinimalLock not working as expected</span></font><o:p></o:p></p> </div> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Hello,<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I have an WinForms application in C# that generates = data files for a graphing application.&nbsp; This application uses log4net to = log progress, information, errors, etc.&nbsp; I also want this application = to be able to view the log file.&nbsp; When I try to open the log file I get = the following error message:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>The process cannot access the file &#8220;C:\....\MyApplication.log&#8221; because it is being used by = another process.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I searched Google and found that I should add the = following line to my configuration file:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;lockingModel type=3D&quot;log4net.Appender.FileAppender+MinimalLock\&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Adding this does not seem to allow access to log = file.&nbsp; I expected to be able to open the log file in Notepad by double-clicking = on it but that also generates the same error.&nbsp; 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.<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>I am using:<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Visual Studio 2005 = Professional<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Microsoft .NET Framework = 2.0<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>log4net = v83.161.120.155<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>Windows XP Pro = w/SP2<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-indent:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo= nt></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Here is my configuration = file:<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;?xml version=3D&quot;1.0&quot; = encoding=3D&quot;utf-8&quot; ?&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;log4net&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;appender name=3D&quot;RollingFile&quot; type=3D&quot;log4net.Appender.RollingFileAppender&quot;&gt;<o:p></o:p></s= pan></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;file value=3D&quot;MyApplication.log&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;appendToFile = value=3D&quot;true&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;maximumFileSize value=3D&quot;100KB&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;maxSizeRollBackups value=3D&quot;2&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;lockingModel type=3D&quot;log4net.Appender.FileAppender+MinimalLock\&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;layout type=3D&quot;log4net.Layout.PatternLayout&quot;&gt;<o:p></o:p></span></fo= nt></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;conversionPattern value=3D&quot;%date [%thread] %-5level %logger - %message%newline&quot; = /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; = &lt;/layout&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;/appender&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;root&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;level = value=3D&quot;DEBUG&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp;&nbsp;&nbsp; &lt;appender-ref ref=3D&quot;RollingFile&quot; /&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&nbsp; &lt;/root&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>&lt;/log4net&gt;<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Am I missing something = here?<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Thanks,<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'><o:p>&nbsp;</o:p></span></font></p> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><b><font size=3D3 = color=3D"#990000" face=3DArial><span = style=3D'font-size:12.0pt;font-family:Arial;color:#990000; font-weight:bold'>Randall Price</span></font><font = color=3D"#990000"><span style=3D'color:#990000'><o:p></o:p></span></font></b></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Secure <st1:City w:st=3D"on"><st1:place = w:st=3D"on">Enterprise</st1:place></st1:City> Technology Initiatives<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Microsoft Implementation = Group</span></font><o:p></o:p></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Virginia Tech Information = Technology</span></font><o:p></o:p></p> <p class=3DMsoNormal><st1:Street w:st=3D"on"><st1:address style=3D"BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: = url(res://ietag.dll/#34/#1001); BACKGROUND-REPEAT: repeat-x" tabIndex=3D"0" w:st=3D"on"><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>1700 Pratt = Drive</span></font></st1:address></st1:Street><o:p></o:p></p> <p class=3DMsoNormal style=3D'margin-bottom:6.0pt'><st1:place = w:st=3D"on"><st1:City w:st=3D"on"><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family: Arial'>Blacksburg</span></font></st1:City><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>, <st1:State = w:st=3D"on">VA</st1:State>&nbsp; <st1:PostalCode = w:st=3D"on">24060</st1:PostalCode></span></font></st1:place><o:p></o:p></= p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=3D"mailto:loganbryant@example.org">loganbryant@example.org</a></span></fon= t><o:p></o:p></p> <p class=3DMsoNormal><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt; font-family:Arial'>Phone:&nbsp;&nbsp;&nbsp;&nbsp; (540) = 231-4396</span></font><o:p></o:p></p> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'><o:p>&nbsp;</o:p></span></font></p> </div> </body> </html> ------_=_NextPart_001_01C776FA.BC6D824A-- From log4net-user-returnloganbryant@example.org Wed Apr 04 22:14:56 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 15105 invoked from network); 4 Apr 2007 22:14:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2007 22:14:56 -0000 Received: (qmail 20677 invoked by uid 500); 4 Apr 2007 22:15:01 -0000 Delivered-To: loganbryant@example.org Received: (qmail 20658 invoked by uid 500); 4 Apr 2007 22:15:01 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 20646 invoked by uid 99); 4 Apr 2007 22:15:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 15:15:01 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO web30511.mail.mud.yahoo.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 04 Apr 2007 15:14:53 -0700 Received: (qmail 43461 invoked by uid 60001); 4 Apr 2007 22:14:32 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=w+6foYeUJ/ILPqTdLrREF69IDsaI9DXJGJlt6jaremYDvV35DOYpj91WGpY7VF/iyv7YsUTqGldKvU73L2DxrKqSrVeOiDWuoIbLksoTSFeDCQYFVfJgF4sPmX+PlNU0hQiNTVjcJ+aFAZzliZlvr9+ea6WnOCT9AlnTvm0rpio= ; Message-ID: <loganbryant@example.org> X-YMail-OSG: nV.2gqEVM1n3z2TY4fxdm4Uv73bWDh4daCxeRC0LE.XS0gIX Received: from [83.161.120.155] by web30511.mail.mud.yahoo.com via HTTP; Wed, 04 Apr 2007 15:14:32 PDT X-Mailer: YahooMailRC/476 YahooMailWebService/83.161.120.155 Date: Wed, 4 Apr 2007 15:14:32 -0700 (PDT) From: Ron Grabowski <loganbryant@example.org> Subject: Re: FileAppender+MinimalLock not working as expected - Correction! To: Log4NET User <loganbryant@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org How are you trying to open the file in code?=0A=0A=0A----- Original Message= ----=0A=0AFrom: "Price, Randall" <loganbryant@example.org>=0A=0ATo: Log4NET User <= loganbryant@example.org>=0A=0ASent: Wednesday, April 4, 2007 4:49:2= 7 PM=0A=0ASubject: RE: FileAppender+MinimalLock not working as expected - C= orrection!=0A=0A=0A When my WinForms application is running I CAN double-= click on the log file from Windows Explorer and open the log file in Notepa= d.=0A=0A =0A=0A But when I click my View Log File button on my applic= ation, I get the =93process cannot access =85 being used by another process= =94 error message. However process should be the same process making the r= equest to open the file for reading.=0A=0A =0A=0A Has anyone ever don= e something like this before? =0A=0A=0A=0A=0A From log4net-user-returnloganbryant@example.org Wed Apr 04 22:25:51 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 18153 invoked from network); 4 Apr 2007 22:25:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Apr 2007 22:25:50 -0000 Received: (qmail 39310 invoked by uid 500); 4 Apr 2007 22:25:55 -0000 Delivered-To: loganbryant@example.org Received: (qmail 39280 invoked by uid 500); 4 Apr 2007 22:25:55 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 39269 invoked by uid 99); 4 Apr 2007 22:25:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 15:25:55 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO web30513.mail.mud.yahoo.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 04 Apr 2007 15:25:47 -0700 Received: (qmail 68765 invoked by uid 60001); 4 Apr 2007 22:25:26 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=govJoz6kM1BrrWhqgEbFn7MpfK4z2/2Iid5QYU+RatXx7IG76Rp42qsTH+sIDyghhaELZInWHvTfdYyEa7GKNKC+PVKFDocNj/3yftYNmK2SRd7AtsEN6GxUdcEug8kGa3xaLOpw1c/rsad7DPv36qwbGR5/qsm1gNFjnNCMEqY=; X-YMail-OSG: .podCpAVM1lpTvUGuz8CSYKk2vVZFf3a7PYTbXIJLBaVkep3BYYVPaN5101709l9SwRaPIKkKmFtuzjvYFz8lllteQ-- Received: from [83.161.120.155] by web30513.mail.mud.yahoo.com via HTTP; Wed, 04 Apr 2007 15:25:26 PDT X-Mailer: YahooMailRC/476 YahooMailWebService/83.161.120.155 Date: Wed, 4 Apr 2007 15:25:26 -0700 (PDT) From: Ron Grabowski <loganbryant@example.org> Subject: Re: FileAppender ExclusiveLock workaround (Not MinimalLock) To: Log4NET User <loganbryant@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Message-ID: <{{EMAIL+PHONE}}> X-Virus-Checked: Checked by ClamAV on apache.org Have you tried something like this: // untested FileAppender fileAppender = new FileAppender(); fileAppender.Writer = new QuietTextWriter( new StreamWriter( new FileStream("logs.txt",FileMode.Append,FileAccess.Write,FileShare.ReadWrite)), new OnlyOnceErrorHandler()); ----- Original Message ---- From: Frogg <loganbryant@example.org> To: loganbryant@example.org Sent: Wednesday, April 4, 2007 4:31:05 PM Subject: FileAppender ExclusiveLock workaround (Not MinimalLock) Hello, We used to use a really old version of log4net (1.2.03) but have since upgraded to 1.2.10. With the old log4net we created a custom FileAppender so that different application domains could log to the same file (this was before the days of MinimalLock). Basically, what we did was to override the OpenFile method to open the file stream in share mode, thus allowing many processes to write to the file at the same time. This is how the code looked that worked with the old log4net dll: ==================Code c#========================= protected override void OpenFile(string rawFileName, bool append) { lock(this) { // Release any current configuration and prepare for new. Reset(); // Make THIS loganbryant@example.org. LogLog.Debug( string.Format( "CustomFileAppender: Opening file for SHARED writing[{0}] append [{1}] ",fileName, append ) ); // Create the directory if needed Directory.CreateDirectory((new FileInfo(fileName)).DirectoryName); // Open the file to allow reading and writing WHILE OPEN FileStream fs = new FileStream(fileName,FileMode.Append,FileAccess.Write,FileShare.ReadWrite); // and store for use in the base class SetQWForFiles(new StreamWriter(fs)); // save the name and append settings base.File = fileName; base.AppendToFile = append; // and write out any header details WriteHeader(); } ==============End Code====================== When we upgraded to the 1.2.10 this code no longer worked. I tried using MinimalLock instead of the above code but that has the unfortunate side effects of being very slow(Lock, Unlock, Lock, Unlock, etc) and allowing some other process to maintain an exclusive lock on the file (no matter how short of time), someone other than the logger (for example, someone is viewing the log file, the application is not able to log events because that person viewing got a writer lock). I would like to be able to redo the code above to work with 1.2.10 but my attempts thus far have been unsuccessfull, if anyone has any ideas that may put me on the right track I would be greatly appreciative. Thanks, -- View this message in context: http://www.nabble.com/FileAppender-ExclusiveLock-workaround-%28Not-MinimalLock%29-tf3528119.html#a9845029 Sent from the Log4net - Users mailing list loganbryant@example.org. From log4net-user-returnloganbryant@example.org Thu Apr 05 00:14:26 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 51033 invoked from network); 5 Apr 2007 00:14:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 5 Apr 2007 00:14:25 -0000 Received: (qmail 97145 invoked by uid 500); 5 Apr 2007 00:14:31 -0000 Delivered-To: loganbryant@example.org Received: (qmail 97122 invoked by uid 500); 5 Apr 2007 00:14:31 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 97111 invoked by uid 99); 5 Apr 2007 00:14:30 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 17:14:30 -0700 X-ASF-Spam-Status: No, hits=2.3 required=10.0 tests=HTML_FONT_BIG,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO out4.smtp.messagingengine.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 17:14:22 -0700 Received: from compute1.internal (compute1.internal [83.161.120.155]) by out1.messagingengine.com (Postfix) with ESMTP id DA664212976 for <loganbryant@example.org>; Wed, 4 Apr 2007 20:14:06 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([83.161.120.155]) by compute1.internal (MEProxy); Wed, 04 Apr 2007 20:14:02 -0400 X-Sasl-enc: X0seS2Rf2KVctLHgA8Z2ME1mlDu3leEXzUQI1Plre16+ 1175732041 Received: from [83.161.120.155] (unknown [83.161.120.155]) by mail.messagingengine.com (Postfix) with ESMTP id 30F163280A for <loganbryant@example.org>; Wed, 4 Apr 2007 20:14:01 -0400 (EDT) Message-ID: <loganbryant@example.org> Date: Wed, 04 Apr 2007 17:13:58 -0700 From: Daniel Essin <loganbryant@example.org> User-Agent: Thunderbird 83.161.120.155 (Windows/20070221) MIME-Version: 1.0 To: Log4NET User <loganbryant@example.org> Subject: Re: FileAppender+MinimalLock not working as expected - Correction! References: <loganbryant@example.org> <loganbryant@example.org> In-Reply-To: <loganbryant@example.org> Content-Type: multipart/alternative; boundary="------------030700020704020101060604" X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------030700020704020101060604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I've been using the following in a web page and it seems to work ok. It gets the latest file created by the rolling appender. I'm not sure that this is adding anything that you don't already know. ----------------------------------- try { string logDir = ConfigurationManager.AppSettings["LogDir"]; DirectoryInfo dirInfo = new DirectoryInfo(logDir); string logFileNameRoot = ConfigurationManager.AppSettings["LogFileNameRoot"]; FileInfo[] fileInfoArray = dirInfo.GetFiles(logFileNameRoot + "*.*", SearchOption.TopDirectoryOnly); Array.Sort(fileInfoArray, new ComparableFileInfo(UtilityFunctions.CompareByOptions.LastWriteTimeDescending)); if (fileInfoArray.Length > 0) { StreamReader st = fileInfoArray[0].OpenText(); string line = st.ReadLine(); do { Response.Write(line + "<p>"); //Response.Write(line + "<p>"); line = st.ReadLine(); } while (!st.EndOfStream); } } catch { } finally { Response.End(); } It uses: -------------------------- public enum CompareByOptions { FileNameAscending, FileNameDescending, LastWriteTimeAscending, LastWriteTimeDescending, LengthAscending, LengthDescending } public class ComparableFileInfo : IComparer { CompareByOptions compareBy = CompareByOptions.FileNameAscending; public ComparableFileInfo(CompareByOptions cBy) { compareBy = cBy; } #region IComparer Members int IComparer.Compare(object x, object y) { FileInfo f1 = (FileInfo)x; FileInfo f2 = (FileInfo)y; switch (compareBy) { case CompareByOptions.FileNameAscending: return string.Compare(f1.Name, f2.Name); case CompareByOptions.FileNameDescending: return string.Compare(f2.Name, f1.Name); case CompareByOptions.LastWriteTimeAscending: return DateTime.Compare(f1.LastWriteTime, f2.LastWriteTime); case CompareByOptions.LastWriteTimeDescending: return DateTime.Compare(f2.LastWriteTime, f1.LastWriteTime); case CompareByOptions.LengthAscending: return (int)(f1.Length - f2.Length); case CompareByOptions.LengthDescending: return (int)(f2.Length - f1.Length); } return -1; } #endregion } ------------------------------------------------------------- Dan Essin Price, Randall wrote: > > 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: loganbryant@example.org <mailto:loganbryant@example.org> > > Phone: (464)853-2585 > > ------------------------------------------------------------------------ > > *From:* Price, Randall [mailto:loganbryant@example.org] > *Sent:* Wednesday, April 04, 2007 4:38 PM > *To:* loganbryant@example.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 v83.161.120.155 > > 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: loganbryant@example.org <mailto:loganbryant@example.org> > > Phone: (464)853-2585 > > > --------------030700020704020101060604 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <font size="+1"><tt>I've been using the following in a web page and it seems to work ok.<br> It gets the latest file created by the rolling appender.<br> </tt></font><font size="+1"><tt>I'm not sure that this is adding anything that you don't already know.</tt></font><br> <font size="+1"><tt>-----------------------------------<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string logDir = ConfigurationManager.AppSettings["LogDir"];<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DirectoryInfo dirInfo = new DirectoryInfo(logDir);<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string logFileNameRoot = ConfigurationManager.AppSettings["LogFileNameRoot"];<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileInfo[] fileInfoArray = dirInfo.GetFiles(logFileNameRoot + "*.*", SearchOption.TopDirectoryOnly);<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Array.Sort(fileInfoArray, new ComparableFileInfo(UtilityFunctions.CompareByOptions.LastWriteTimeDescending));<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (fileInfoArray.Length &gt; 0)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StreamReader st = fileInfoArray[0].OpenText();<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string line = st.ReadLine();<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; do<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Response.Write(line + "&lt;p&gt;");<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Response.Write(line + "&lt;p&gt;");<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; line = st.ReadLine();<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } while (!st.EndOfStream);<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; catch<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; finally<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Response.End();<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> It uses:<br> --------------------------<br> &nbsp;&nbsp;&nbsp; public enum CompareByOptions<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileNameAscending,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileNameDescending,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LastWriteTimeAscending,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LastWriteTimeDescending,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LengthAscending,<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LengthDescending<br> &nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp; public class ComparableFileInfo : IComparer<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CompareByOptions compareBy = CompareByOptions.FileNameAscending;<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public ComparableFileInfo(CompareByOptions cBy)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; compareBy = cBy;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> <br> #region IComparer Members<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp; IComparer.Compare(object x, object y)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileInfo f1 = (FileInfo)x;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileInfo f2 = (FileInfo)y;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch (compareBy)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.FileNameAscending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return string.Compare(f1.Name, f2.Name);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.FileNameDescending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return string.Compare(f2.Name, f1.Name);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.LastWriteTimeAscending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return DateTime.Compare(f1.LastWriteTime, f2.LastWriteTime);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.LastWriteTimeDescending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return DateTime.Compare(f2.LastWriteTime, f1.LastWriteTime);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.LengthAscending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (int)(f1.Length - f2.Length);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; case CompareByOptions.LengthDescending:<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (int)(f2.Length - f1.Length);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> #endregion<br> &nbsp;&nbsp;&nbsp; }<br> -------------------------------------------------------------<br> <br> Dan Essin<br> <br> </tt></font><br> Price, Randall wrote: <blockquote cite="loganbryant@example.org" type="cite"> <meta http-equiv="Content-Type" content="text/html; "> <meta name="Generator" content="Microsoft Word 11 (filtered medium)"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PostalCode"> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"><o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="Street"> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="address"><o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"><!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <style> <!-- /* Font Definitions */ @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal; font-family:Arial; color:windowtext;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:Arial; color:navy;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </style></o:SmartTagType></o:SmartTagType></o:SmartTagType></o:SmartTagType></o:SmartTagType></o:SmartTagType> <div class="Section1"> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Correction!<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">When my WinForms application is running I CAN double-click on the log file from Windows Explorer and open the log file in Notepad.<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">But when I click my View Log File button on my application, I get the &#8220;process cannot access &#8230; being used by another process&#8221; error message.&nbsp; However process should be the same process making the request to open the file for reading.<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Has anyone ever done something like this before?<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Thanks,<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;<o:p></o:p></span></font></p> <div> <p class="MsoNormal" style="margin-bottom: 6pt;"><b><font color="#990000" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: rgb(153, 0, 0); font-weight: bold;">Randall Price</span></font><font color="#990000"><span style="color: rgb(153, 0, 0);"><o:p></o:p></span></font></b></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Secure Enterprise Technology Initiatives<o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Microsoft Implementation Group</span></font><font color="navy"><span style="color: navy;"><o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Virginia Tech Information Technology</span></font><font color="navy"><span style="color: navy;"><o:p></o:p></span></font></p> <p class="MsoNormal"><st1:Street w:st="on"><st1:address style="background-position: left bottom; background-image: url(res://ietag.dll/#34/#1001); background-repeat: repeat-x;" tabindex="0" w:st="on"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">1700 Pratt Drive</span></font></st1:address></st1:Street><font color="navy"><span style="color: navy;"><o:p></o:p></span></font></p> <p class="MsoNormal" style="margin-bottom: 6pt;"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Blacksburg, VA&nbsp; 24060</span></font><font color="navy"><span style="color: navy;"><o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:loganbryant@example.org">loganbryant@example.org</a></span></font><font color="navy"><span style="color: navy;"><o:p></o:p></span></font></p> <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Phone:&nbsp;&nbsp;&nbsp;&nbsp; (464)853-2585</span></font><o:p></o:p></p> </div> <div> <div class="MsoNormal" style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> <hr tabindex="-1" align="center" size="2" width="100%"></span></font></div> <p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Price, Randall [<a class="moz-txt-link-freetext" href="mailto:loganbryant@example.org">mailto:loganbryant@example.org</a>] <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, April 04, 2007 4:38 PM<br> <b><span style="font-weight: bold;">To:</span></b> <a class="moz-txt-link-abbreviated" href="mailto:loganbryant@example.org">loganbryant@example.org</a><br> <b><span style="font-weight: bold;">Subject:</span></b> FileAppender+MinimalLock not working as expected</span></font><o:p></o:p></p> </div> <p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Hello,<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I have an WinForms application in C# that generates data files for a graphing application.&nbsp; This application uses log4net to log progress, information, errors, etc.&nbsp; I also want this application to be able to view the log file.&nbsp; When I try to open the log file I get the following error message:<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">The process cannot access the file &#8220;C:\....\MyApplication.log&#8221; because it is being used by another process.<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I searched Google and found that I should add the following line to my configuration file:<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock\" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Adding this does not seem to allow access to log file.&nbsp; I expected to be able to open the log file in Notepad by double-clicking on it but that also generates the same error.&nbsp; 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.<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am using:<o:p></o:p></span></font></p> <p class="MsoNormal" style="text-indent: 0.5in;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Visual Studio 2005 Professional<o:p></o:p></span></font></p> <p class="MsoNormal" style="text-indent: 0.5in;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Microsoft .NET Framework 2.0<o:p></o:p></span></font></p> <p class="MsoNormal" style="text-indent: 0.5in;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">log4net v83.161.120.155<o:p></o:p></span></font></p> <p class="MsoNormal" style="text-indent: 0.5in;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Windows XP Pro w/SP2<o:p></o:p></span></font></p> <p class="MsoNormal" style="text-indent: 0.5in;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Here is my configuration file:<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&lt;?xml version="1.0" encoding="utf-8" ?&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&lt;log4net&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp; &lt;appender name="RollingFile" type="log4net.Appender.RollingFileAppender"&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;file value="MyApplication.log" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;appendToFile value="true" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;maximumFileSize value="100KB" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;maxSizeRollBackups value="2" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock\" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;layout type="log4net.Layout.PatternLayout"&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;conversionPattern value="%date [%thread] %-5level %logger - %message%newline" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp; &lt;/appender&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp; &lt;root&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;level value="DEBUG" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp;&nbsp;&nbsp; &lt;appender-ref ref="RollingFile" /&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&nbsp; &lt;/root&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">&lt;/log4net&gt;<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Am I missing something here?<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Thanks,<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><o:p>&nbsp;</o:p></span></font></p> <p class="MsoNormal" style="margin-bottom: 6pt;"><b><font color="#990000" face="Arial" size="3"><span style="font-size: 12pt; font-family: Arial; color: rgb(153, 0, 0); font-weight: bold;">Randall Price</span></font><font color="#990000"><span style="color: rgb(153, 0, 0);"><o:p></o:p></span></font></b></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Secure <st1:City w:st="on"><st1:place w:st="on">Enterprise</st1:place></st1:City> Technology Initiatives<o:p></o:p></span></font></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Microsoft Implementation Group</span></font><o:p></o:p></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Virginia Tech Information Technology</span></font><o:p></o:p></p> <p class="MsoNormal"><st1:Street w:st="on"><st1:address style="background-position: left bottom; background-image: url(res://ietag.dll/#34/#1001); background-repeat: repeat-x;" tabindex="0" w:st="on"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">1700 Pratt Drive</span></font></st1:address></st1:Street><o:p></o:p></p> <p class="MsoNormal" style="margin-bottom: 6pt;"><st1:place w:st="on"><st1:City w:st="on"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Blacksburg</span></font></st1:City><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">, <st1:State w:st="on">VA</st1:State>&nbsp; <st1:PostalCode w:st="on">24060</st1:PostalCode></span></font></st1:place><o:p></o:p></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:loganbryant@example.org">loganbryant@example.org</a></span></font><o:p></o:p></p> <p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Phone:&nbsp;&nbsp;&nbsp;&nbsp; (464)853-2585</span></font><o:p></o:p></p> <p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p> </div> </blockquote> </body> </html> --------------030700020704020101060604-- From log4net-user-returnloganbryant@example.org Thu Apr 05 13:24:48 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 91036 invoked from network); 5 Apr 2007 13:24:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 5 Apr 2007 13:24:47 -0000 Received: (qmail 17233 invoked by uid 500); 5 Apr 2007 13:24:53 -0000 Delivered-To: loganbryant@example.org Received: (qmail 17214 invoked by uid 500); 5 Apr 2007 13:24:52 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 17203 invoked by uid 99); 5 Apr 2007 13:24:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 06:24:52 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of loganbryant@example.org designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO rivendell.cc.vt.edu) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 06:24:44 -0700 Received: from elessar.cc.vt.edu ([83.161.120.155]) by rivendell.cc.vt.edu with Microsoft SMTPSVC(5.0.2195.6713); Thu, 5 Apr 2007 09:24:23 -0400 X-MIMEOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: FileAppender+MinimalLock not working as expected - Correction! Date: Thu, 5 Apr 2007 09:24:21 -0400 Message-ID: <loganbryant@example.org> In-reply-to: <loganbryant@example.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: FileAppender+MinimalLock not working as expected - Correction! Thread-index: Acd3Bq4//JiHwudHSb2MzWB2WZ3FpwAfsa/g References: <loganbryant@example.org> From: "Price, Randall" <loganbryant@example.org> To: "Log4NET User" <loganbryant@example.org> X-OriginalArrivalTime: 05 Apr 2007 13:24:23.0640 (UTC) FILETIME=[B9E38580:01C77785] X-Virus-Checked: Checked by ClamAV on apache.org Here is the code to open and read the log file: StreamReader sr =3D new StreamReader(strFileName); string strData =3D sr.ReadToEnd(); sr.Close(); txtData.Text =3D strData; As you can see I am not doing anything complex, just opening the file and reading the contents into a TextBox. Randall Price Secure Enterprise Technology Initiatives Microsoft Implementation Group Virginia Tech Information Technology 1700 Pratt Drive Blacksburg, VA 24060 Email: loganbryant@example.org Phone: (464)853-2585 -----Original Message----- From: Ron Grabowski [mailto:loganbryant@example.org]=20 Sent: Wednesday, April 04, 2007 6:15 PM To: Log4NET User Subject: Re: FileAppender+MinimalLock not working as expected - Correction! How are you trying to open the file in code? ----- Original Message ---- From: "Price, Randall" <loganbryant@example.org> To: Log4NET User <loganbryant@example.org> Sent: Wednesday, April 4, 2007 4:49:27 PM Subject: RE: FileAppender+MinimalLock not working as expected - 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. =20 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. =20 Has anyone ever done something like this before?=20 From log4net-user-returnloganbryant@example.org Thu Apr 05 13:25:25 2007 Return-Path: <log4net-user-returnloganbryant@example.org> Delivered-To: loganbryant@example.org Received: (qmail 91942 invoked from network); 5 Apr 2007 13:25:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 5 Apr 2007 13:25:24 -0000 Received: (qmail 23232 invoked by uid 500); 5 Apr 2007 13:25:29 -0000 Delivered-To: loganbryant@example.org Received: (qmail 23200 invoked by uid 500); 5 Apr 2007 13:25:29 -0000 Mailing-List: contact loganbryant@example.org; run by ezmlm Precedence: bulk list-help: <mailto:loganbryant@example.org> list-unsubscribe: <mailto:loganbryant@example.org> List-Post: <mailto:loganbryant@example.org> Reply-To: "Log4NET User" <loganbryant@example.org> List-Id: <log4net-user.logging.apache.org> Delivered-To: mailing list loganbryant@example.org Received: (qmail 23189 invoked by uid 99); 5 Apr 2007 13:25:29 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 06:25:29 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of loganbryant@example.org designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO talk.nabble.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 06:25:21 -0700 Received: from [83.161.120.155] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HZRxV-00006v-7y for loganbryant@example.org; Thu, 05 Apr 2007 06:25:01 -0700 Message-ID: <loganbryant@example.org> Date: Thu, 5 Apr 2007 06:25:01 -0700 (PDT) From: Frogg <loganbryant@example.org> To: loganbryant@example.org Subject: Re: FileAppender ExclusiveLock workaround (Not MinimalLock) In-Reply-To: <{{EMAIL+PHONE}}> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: loganbryant@example.org References: <loganbryant@example.org> <{{EMAIL+PHONE}}> X-Virus-Checked: Checked by ClamAV on apache.org Thanks for the suggestion, I tried to add this to my code however it doesnt seem to work, I may be missing some initialization command somewhere.... It will create the log file but it will not input any text into it. Ron Grabowski wrote: > > Have you tried something like this: > > // untested > FileAppender fileAppender = new FileAppender(); > fileAppender.Writer = > new QuietTextWriter( > new StreamWriter( > new > FileStream("logs.txt",FileMode.Append,FileAccess.Write,FileShare.ReadWrite)), > new OnlyOnceErrorHandler()); > > ----- Original Message ---- > From: Frogg <loganbryant@example.org> > To: loganbryant@example.org > Sent: Wednesday, April 4, 2007 4:31:05 PM > Subject: FileAppender ExclusiveLock workaround (Not MinimalLock) > > > Hello, > > We used to use a really old version of log4net (1.2.03) but have since > upgraded to 1.2.10. With the old log4net we created a custom FileAppender > so that different application domains could log to the same file (this was > before the days of MinimalLock). Basically, what we did was to override > the > OpenFile method to open the file stream in share mode, thus allowing many > processes to write to the file at the same time. > > This is how the code looked that worked with the old log4net dll: > > ==================Code c#========================= > protected override void OpenFile(string rawFileName, bool append) > { > lock(this) > { > // Release any current configuration and prepare for new. > Reset(); > > // Make THIS loganbryant@example.org. > LogLog.Debug( > string.Format( > "CustomFileAppender: Opening file for SHARED writing[{0}] > append [{1}] > ",fileName, append ) ); > > // Create the directory if needed > Directory.CreateDirectory((new FileInfo(fileName)).DirectoryName); > > // Open the file to allow reading and writing WHILE OPEN > FileStream fs = new > FileStream(fileName,FileMode.Append,FileAccess.Write,FileShare.ReadWrite); > > // and store for use in the base class > SetQWForFiles(new StreamWriter(fs)); > > // save the name and append settings > base.File = fileName; > base.AppendToFile = append; > > // and write out any header details > WriteHeader(); > } > ==============End Code====================== > > When we upgraded to the 1.2.10 this code no longer worked. I
{'source': 'Apache Software Foundation Public Mail Archives'}