Using java.util.logging to log on the console

烂漫一生 提交于 2019-12-03 04:37:56

Very simple, a logger can have several handlers, with each a different level.

handler.setLevel(Level.ALL);

Logging on the standard System.out stream could be easily done by adding a StreamHandler handler:

logger.addHandler(new StreamHandler(System.out, new SimpleFormatter()))
user949300

I'm no expert on java logging, but if you change log.fine() to log.info() it will print. There's something fishy about fine - in practice, I never used it. Hopefully somebody who knows more can answer that.

ADDED: Yes, fine is special. I found an earlier SO answer for this:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!