How to configure the jdk14 logging's pattern

前端 未结 2 1219
抹茶落季
抹茶落季 2020-12-06 12:17

I guess I can chnage pattern by adding the line java.util.logging.ConsoleHandler.pattern, however where to check the pattern information like %u %h etc?

2条回答
  •  隐瞒了意图╮
    2020-12-06 13:03

    Edit: The below was written at the time for Java 6. For 7 and later, refer to David's answer below.

    AFAIK there is no such property. There is a java.util.logging.FileHandler.pattern but this is to set the pattern of the output filename, not of the logging format.

    The way you configure the output format in the util logging API is by setting the Formatter. By default, a SimpleFormatter is attached to your ConsoleHandler. This formatter simply hardcodes the pattern and doesn't allow you to set it.

    If you need a different output format, you'll have to either implement your own Formatter, or use a different logging framework, such as logback.

提交回复
热议问题