logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meera Rajaram" <mraja...@vitalimages.com>
Subject RE: Using BufferingForwardingAppender based on size of message vs number of messages
Date Tue, 18 Apr 2006 13:58:13 GMT
>What other appenders besides the FileAppender do you think would
benefit from this?
The buffering of messages is mainly useful for FileAppender. The
internal buffering mechanism of FileStream that you gave below would
work fine if I were using Exclusive locking. But, in my case since I
need to allow multiple processes to log to the same file, I am forced to
use minimal locking. 


Thanks,
Meera.

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Monday, April 17, 2006 11:27 PM
To: Log4NET User
Subject: RE: Using BufferingForwardingAppender based on size of message
vs number of messages

--- Ron Grabowski <rongrabowski@yahoo.com> wrote:

> I think a better starting point would be to write a
> BufferedRenderedMessageLengthFileAppender (long name!) and put the
> bufferLength property on that. 

This seemed to work too. It buffers writes to a FileAppender in 25k
chunks.

public class ExclusiveLock25k : FileAppender.LockingModelBase
{
 // copy the contents of the ExclusiveLock class because 
 // its m_stream field is private

 public override void OpenFile(string filename, bool append,Encoding
encoding)
 {

  // snip 

  m_stream = new FileStream(filename, fileOpenMode, FileAccess.Write,
FileShare.Read, 25000); 
 } 
}

<appender name="FileAppender" type="log4net.Appender.FileAppender">
 <file value="25kBufferedLogs.txt" />
 <appendToFile value="false" />
 <layout type="log4net.Layout.PatternLayout" />
 <lockingModel type="Company.Logging.ExclusiveLock25k, Company.Logging"
/>
 <immediateFlush value="false" />
</appender>

I think the default value for a FileStream is 4k.

________________________________________________________________________
This email has been scanned for all viruses and found to be virus free.
If you have questions regarding this scanning please visit the
Information Services area of http://home.vitalimages.com
________________________________________________________________________

Mime
View raw message