tags:

views:

54

answers:

2

Dear Devs

I am using Log4net to produce different kind of logs and using RollingFileAppenders which rolls on a given size.

Now i have a new requirement that a log should be visible on a windows form therefore i am looking for some event that can be handled on each log entry within my application so i can display that particular log entry in my form as well.

Or there may be some appender which gives such functionality.

Any idea on this?

+4  A: 

I'd suggest writing your own appender - it's really easy to do:

  1. Create a class that inherits from AppenderSkeleton
  2. Override the Append method

Simple!

Here is an example of a custom appender that updates a textbox.

Cocowalla
Any sample to this?
Mubashar Ahmad
I just added an example for you. You can locate others on http://www.google.com/codesearch if you need them
Cocowalla
Thanks buddy nice advice working great.
Mubashar Ahmad
A: 

As I suggest in this answer, you could set up a MemoryAppender and monitor log messages in memory. It does not expose an event but you could easily set up a timer that retrieves the latest messages.

Peter Lillevold
Oh-key, a bit of constructive criticism with the downvote is always appreciated. If not, why downvote?
Peter Lillevold
Author of the question can't take the responsibility of this deed :) Voter must added a comment.
Mubashar Ahmad
@Mubashar Ahmad - no problem, glad you got a solution :)
Peter Lillevold