How can you implement Buffered Logging?

Topics: Development Team Discussion, User Discussion
Developer
Oct 2, 2009 at 1:37 PM

 

Hello,

I asked this question on http://entlib.codeplex.com/Thread/View.aspx?ThreadId=70762  before, but I wasn't sure if these two discussion lists are the same, so I am asking it here. If you already read this question, please disregard it.

-----

I created a CustomTraceListener based on http://entlib.codeplex.com/Thread/View.aspx?ThreadId=51701  . It's working fine but I want to add buffering capability to it.

Using an arraylist as MethodEntry holder was suggested, which is good , but what if the buffer size doesn't reach the preset number (20)? How will the list get flushed then?

Isn't there a buffering option for logging application block similar to healthmonitoring with  maxBufferSize, maxFlushSize, urgentFlushThreshold, regularFlushInterval, urgentFlushInterval, maxBufferThreads  etc.. parameters?

Thank you,

Burak

Coordinator
Oct 7, 2009 at 11:00 PM
Edited Dec 11, 2009 at 9:23 AM

Hi Burak,

 

The discussion lists are not the same and are managed by different people. Today is the first day I have had a chance to do some forum support since you registered this discussion but I hope to be able to give you an answer at some stage, I do not know the answer at the moment however, I would suggest that you need some sort of timer so that the log gets written away either when the buffer fills up or when a time limit expires, whichever is sooner. That way your buffer will always get flushed even if it does not fill up.

 

Cheers...   Steve

 

 

Coordinator
Nov 23, 2009 at 7:46 PM

Hi Burak,

I suspect by now you have solved the buffering issue? However, I did promise to get back to you.  The closest to a form of buffering is the MSMQ listener. Although this is not buffering, per say, it is asynchronous and thus a "fire and forget" logging method.  For true buffering I still come back to the timer idea. If you have been looking at the timer idea for a custom trace listener it would make a truly great contribution to the LAB, a BufferedEventLogTraceListener or BufferedRollingFlatFileTraceListener etc.

Cheers...   Steve

Developer
Dec 2, 2009 at 6:44 PM

Hi Steve,

I implemented a BufferedDbTraceListener with buffering and time out flushing.  How can I get the code to you?

Thanks,

Burak

Coordinator
Dec 8, 2009 at 5:42 PM
Edited Dec 11, 2009 at 9:24 AM

Hi Burak,

I have made you a developer contributor (login as burak72) to the project so you will be able to put your code directly into the project using source control. There are many ways of doing it and all are detailed under the source code tab in the right hand column under "Source Control Setup". I have finished upgrading the Logging block to v4.1 so if you could place your code in the EntLibContrib41Src branch following the general project, coding and naming style there. For reference I have simply copied the style from the Enterprise Library v4.1 source code.

Thanks for your contribution and happy coding.

Cheers...   Steve