How can I let my JDK logger use my customized formatter implementation without specifying a properties file? I want to set the format by programming.
for example I have my implementation like:
My Formatter e开发者_如何学JAVAxtends Formatter {...}
Assuming that you have already built the Formatter implementation, you'll need to bind this to a Handler instance, so that the said handler will apply the formatter when logging the LogRecord objects (after all, that's how the Logging API was designed).
This is done by get a reference to the Handler instance of interest (you'll need to manage the creation of handlers in order to get a reference to them), and then invoking the setFormatter() method on it.
精彩评论