The FileAppender (and RollingFileAppender) takes an exclusive lock on
the output file. This prevents multiple applications writing to the same
log file. As you have 2 instances of the same application that are
presumably using the same log4net config file then it is rather
challenging to write to different files. There are a couple of ways
around this, firstly you can subclass the FileAppender and override the
File property to unique the file name (e.g. add the process id).
Alternatively you could try using the latest version of log4net from CVS
which supports using a patterned string to add the process id to the
file name as follows:

<file type="log4net.Util.PatternString" value="log-[%processid].txt" />

Nicko

> -----Original Message-----
> From: Nick Jagger [mailto:[EMAIL PROTECTED] 
> Sent: 03 March 2005 10:53
> To: [email protected]
> Subject: RollingFileAppender Problems using Multiple App Instances
> 
> Hi,
> 
> I'm having problems trying to log to a log file using 
> multiple instances of an .exe. I've seen this problem on the 
> forum a few times but unfortunately can't seem to find any 
> satisfactory answers.
> 
> Some solutions point to using a RemotingAppender but 
> unfortunately a) I'm having trouble finding documentation on 
> how exactly to use this, and b) I suspect this approach 
> requires a completely separate program running to handle the 
> remote logging calls, something I'm loathe to having to run - 
> why should I need a separate dedicated application just to 
> write to a log file??
> 
> Additionally, I've tried setting up 2 different log files, 
> one for each instance of my app., but again once the first 
> instance calls Configure() (using app.config) it creates and 
> locks both files! Argghhhhh...!! Sorry, but I'm really 
> starting to pull my hair out over this one, any help at all 
> would be really appreciated.
> 
> Thanks,
> Nick
> 
> 
> **********************************************************************
> The contents of this e-mail are subject to contract in all 
> cases and William Hill PLC, its subsidiaries or affiliates 
> make no contractual commitment save where confirmed by hard copy.  
> 
> The contents of this e-mail do not necessarily represent the 
> views of William Hill PLC, its subsidiaries or affiliates.  
> We accept no liability, including liability for negligence, 
> in respect of any statement in this e-mail. 
> This e-mail and any files transmitted with it are 
> confidential, may be subject to legal privilege and intended 
> solely for the use of the individual or entity to which they 
> are addressed.  If you are not the intended recipient, you 
> are hereby notified that any use or dissemination of this 
> communication is strictly prohibited.  If you have received 
> this e-mail in error, please notify us immediately, then 
> delete this e-mail.  
> 
> Please note that William Hill can accept no responsibility 
> for viruses and it is your responsibility to scan any emails 
> and their attachments.
> 
> This message was from William Hill PLC whose registered 
> office is Greenside House, 50 Station Road, Wood Green, 
> London N22 7TP.  Company Registration Number: 4212563 England.
> **********************************************************************
> 
> 

Reply via email to