My first question on the log4net was on a similiar topic :-) I wanted to know 
how I could make a FileAppender recognize the tilda as the application's 
virtual path in ASP.Net. This is a simple solution from Josh Kewley that I had 
overlooked:

public class GuidRollingFileAppender : RollingFileAppender
{
    public override string File 
    {
        get{return base.File;}
        set{base.File = Guid.NewGuid() + "-" + value;}
    }
}

----- Original Message ----
From: Steve Burkett <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]; [email protected]
Sent: Tuesday, November 14, 2006 2:39:41 PM
Subject: RE: RollingFileAppender &  concurrency

(thanks Ron for your help on this! :)

After researching this a bit, neither %processid nor minimal lock is ideal.  
What would be ideal, is if I could hook into the rollingfileappender's File 
property so that we can try something like this:

(1) create a name (like  Foo.log, based on the file name specified in the 
config file for the rollingfileappender)
(2) try to open the file 
(3) if it opens, good, that's the file name
(4) if it doesn't, then try another using a deterministic pattern: (e.g. 
"Foo.log.Alt1"), until the appender can file a file name that is not locked.   
This file name then be the basis for rolling file names (like Foo.log.Alt1.1)

We need file names to be deterministic, but work in a webgarden scenario.




-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 13, 2006 7:42 PM
To: [email protected]
Subject: Re: RollingFileAppender & concurrency

If you want the processid pattern to be processed, you need to use a file node 
with type PatternString:

<appender name="RollingFileAppender" 
type="log4net.Appender.RollingFileAppender">
 <file type="log4net.Util.PatternString" value="[%processid].log" />
 <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
 <appendToFile value="false" />
 <layout type="log4net.Layout.SimplePatternLayout" />
</appender>

Have you tried an appender node that uses the alternate lockingModel node and 
PatternString file type?

----- Original Message ----
From: Steve Burkett <[EMAIL PROTECTED]>
To: Log4NET User <[email protected]>; [EMAIL PROTECTED]
Sent: Monday, November 13, 2006 8:46:33 PM
Subject: RE: RollingFileAppender &  concurrency



I just saw this blog entry that suggest using %processid. This would be ideal...


    http://piers7.blogspot.com/2006/02/using-log4nets-fileappender-in-web.html

    <appender name="File" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" 
value="C:\temp\MyApp_[%processid].log" />

However,  on my system, using

    <appender name="Loadtest.Debug" type="log4net.Appender.RollingFileAppender, 
log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905">
            <param name="File" value=".\[%processid]LoadTest.log" />

Created a file name " [%processid]LoadTest.log", and showed same locking 
contentions.

We have to use rollingfileappenders, because our customers require us to have 
NO additional dependencies on databases. 



-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]

Sent: Monday, November 13, 2006 5:18 PM
To: Log4NET User
Subject: Re: RollingFileAppender & concurrency

Are you generating a lot of logs? Keep in mind that the RollingFileAppender is 
not a database. Have you looking using something like MSDE and the 
AdoNetAppender as a storage place for logs on each machine? This link shows how 
to setup an alternate locking model on a FileAppender:

http://logging.apache.org/log4net/release/config-examples.html#fileappender

Opening and closing a file after each write will never be as fast as an 
exclusive lock.



----- Original Message ----

From: Steve Burkett <[EMAIL PROTECTED]>

To: [email protected]

Sent: Monday, November 13, 2006 6:50:25 PM

Subject: RollingFileAppender &  concurrency



Hello,


    


   We have a .Net v2 asp.net webservice that uses log4net. Our customers want 
to run our product in a webgarden (multiple processes running on the same 
machine).  Each process, uses the same web.config, and thus the same 
RollingFileAppender file name.

    


   Will the service interleave the log calls to the single file correct? (a 
simple test I did with a console app, running in two windows, didn’t interleave 
correctly).

    


   Is there a switch on RollingFileAppender to allow concurrency?  Another 
(file based) appender?

    


   Thanks! J










=======
Notice: This e-mail message, together with any attachments, contains
information of Symyx Technologies, Inc. or any of its affiliates or
subsidiaries that may be confidential, proprietary, copyrighted,
privileged and/or protected work product, and is meant solely for
the intended recipient. If you are not the intended recipient, and
have received this message in error, please contact the sender
immediately, permanently delete the original and any copies of this
email and any attachments thereto.








Reply via email to