Subclassing java.util.logging.Formatter doesn't work

后端 未结 5 865
自闭症患者
自闭症患者 2021-01-06 16:23

I am using java.util.logging for logging (I don\'t want to use log4j or anything else).

This is my complete private logging.properties:

         


        
5条回答
  •  悲哀的现实
    2021-01-06 16:49

    I found that unless you set the format via the config, it does not apply the formatter. I tested this on JDK 11.

    handlers= java.util.logging.FileHandler
    .level= INFO
    java.util.logging.FileHandler.pattern = my.log
    java.util.logging.FileHandler.limit = 500000
    java.util.logging.FileHandler.count = 40
    java.util.logging.FileHandler.formatter = com.mycomp.myproj.LogFormatter
    com.mycomp.myproj.LogFormatter.format = %n
    

    i.e. add the last line com.mycomp.myproj.LogFormatter.format = %n

提交回复
热议问题