I believe that my explication has been a little bad.
I want that the developer that uses the logger only call (for example) Logger.getLogger().entering("class","method",...) and he don't worry about nothing more. I don't want that the person at uses the logger have to catch the exception in his program for the correct operation of the logger.
I want that the logger knows when a exception has throw by any cause and then the logger write the rest of the buffer to the file.
I believe that when a exception throws, the garbage collector destroy the class but this not happen.
I'm looking for something like this:
In the constructor of the logger (the logger uses a singleton pattern for his creation), it registrates how listener of a event.
This event will be launch when a exception (anything exception) has throw in the source that uses the logger.
Then the looger at be registred like listener of this event can flush the buffer to the file.
I don't kwow if this can be possible or not.