A good example of custom log4net appender outputting text directly to a asp.net control ( custom control , Label , etc)?
Question
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 ...
Solution
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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow