How do I use Logger’s MemoryHandler class?

In this example we demo the use of Logger‘s MemoryHandler
to log only when some conditions happen in our application, for example when a
Level.SEVERE message is logged.

We create an instance of MemoryHandler that will delegate the log to
FileHandler class and it logs the last 100 record until a Level.SEVERE
message is logged.

To check if the message is logged you can open the myapp.log file
created by this small program.