Appenders define their own layout. One appender could use a simple
"%message%newline" pattern while another could use the more verbose
XmlLayoutSchemaLog4j layout.

Isn't it going to be difficult to get all the appenders to flush at the
same time if their layouts are all different?

I had an idea of extending BufferingForwardingAppender and overriding
its AddAppender method to make sure TextWriterAppender being added had
their QuietTextWriter property set to a CountingQuietTextWriter. After
each append, you could retrieve the Count property from the
CountingQuietTextWriter and generate a simple key based on the
appender's name and store that value in the Repository's property bag
so the evaluator can access it and decide if it needs to issue a flush:

 <appender name="MyBufferingForwardingAppender" 
  type="Company.Logging.BufferingForwardingAppender" >
  <evaluator type="RenderedMessageLengthEvaluator">
   <appender-ref ref="FileAppender1" />
   <flushOnRenderedMessageLength value="5000000" />
  </evaluator>
  <evaluator type="RenderedMessageLengthEvaluator">
   <appender-ref ref="FileAppender2" />
   <flushOnRenderedMessageLength value="10000000" />
  </evaluator>
 </appender>

Buffering up 10mb of data in memory then writing it to an appender will
probably cause your application to slowdown a bit don't you think?

Confused yet? I am :-) I don't think the BufferingForwardingAppender
can do what you need it to do. Maybe there's a different solution.
Could you give us more detail as to what you're trying to accomplish?

--- Meera Rajaram <[EMAIL PROTECTED]> wrote:

> Thanks Ron! This works great!! The only problem that I am having now
> is
> that the size of the message is currently considering just the
> RenderedMessage.Length - but I need to get the total size of the
> message
> after the layout has been applied. So if I am using Xml layout, I
> need
> to get the size of the entire xml message that would get written for
> that logging event. Is there any way to get this?
> 
> Thanks,
> Meera.

Reply via email to