I would like to add a memory appender to the root logger so that I can connect to the application and get the last 10 events. I only ever want to keep the last 10. I am worried about this appender consuming all too much memory. The application is designed to run 24/7. Or is there another way?
Share
I guess, you may need to create a custom Appender class that derives from
MemoryAppenderand overrides the output storage by counting the number of messages currently displayed. You can store messages in a list, and, in theAppendmethod, determine if the list already has maximum number of messages. If so, you delete the oldest message and add the new one to the list.