I’m currently writing an own java.util.logging.Handler, and I dont really understand the concept there…
I have my publish method here which contains the logic to see if a LogRecord should be shown, a Formatter (or just SimpleFormatter if the .getFormatter() == null) and finally i put the formatted String into a Cache.
Now i wrote the flush() Method and I’m getting in trouble here: The flush() Method is never called by Java, so when an Error occured, its not shown. I put a call of flush() into my publish() Method and now i can see the log messages… So i dont see the conecept here? When should flush() called and by whom? Or do I have to make it like i do it now, and call flush() by my own in the publish() Method?
If you take a look to this example: http://www.java2s.com/Code/Java/Language-Basics/HowtowritecustomLoghandler.htm they dont even to anything with the flush() Method
Probably a bit late now but for the benefit of others…
Im seeing something similar, and assumed similar behaviour to you
I had a look at the usages of it and it seems to be a way to do a flush in a standard way, and seems to be guarantee you will be flushed on close more than anything.
Some people “flush themselves”, I suppose guaranteeing that superclasses can benefit from the flush as well also.
Finally since there is no threshold control on this flush and since Im not seeing it being called in debug sessions, or code to call it I don’t think Java gives us anything in this regard.