The example code I gave for the extended ExclusiveLock class could be applied to an extended MinimalLock class too.
If you set your buffer to be some arbitrary length, you're not going to be writing out your buffers on message boundries. The log file will have a partially written message (becuase your 10000 buffer will have been filled and flushed) then another process will open the file and write its partial message. Don't you think that's going to be a problem? I still don't understand the requirement for the log file to always be exactly the size of your buffer (i.e. if the buffer were 10000 bytes then your log file would always be exactly 0, 10000, 20000, etc. bytes). Why can't your log file be a little over/under like 10034 bytes or 19993 bytes? You're going to have to write some complicated logic to pad the file with spaces to make sure the file is always buffer aligned. --- Meera Rajaram <[EMAIL PROTECTED]> wrote: > >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:[EMAIL PROTECTED] > 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 <[EMAIL PROTECTED]> 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 > ________________________________________________________________________ >
