Thursday, May 5, 2011

A good example of custom log4net appender outputting text directly to a asp.net control ( custom control , Label , etc) ?!

I do have db appender and know how to get the output to a custom "logging" page ... The idea is to have a quick and dirty switch to write for example to the Response object ...

From stackoverflow
  • This really sounds like a dirty hack but you could get away with it using a MemoryAppender. Here's some sample code on how to get to the log data:

    var memoryAppender = (MemoryAppender)LogManager.GetRepository()
        .GetAppenders().Single(x => x.Name == appenderName);
    
    var events = memoryAppender.GetEvents();
    

    After picking the latest events from the appender for rendering you should probably do a

    memoryAppender.Clear();
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.