2

I am using JUL for logging, I have a properties file. I want to log datetime in milliseconds in my log file.

This is my property:

java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n

Above logs something like this:

Dec 05, 2016 5:08:06 PM ...

How can I also show millisecond?

Minato Namikaze
  • 576
  • 1
  • 7
  • 22

2 Answers2

9

https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html shows all possible formatting options, which are used also by the SimpleFormatter.

So in your case it is %1$tL for the milliseconds.

Roland
  • 22,259
  • 4
  • 57
  • 84
3

Use %1$tL:

java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS.%1$tL %1$Tp %2$s%n%4$s: %5$s%n
                                                                                ^^^

I based this answer off this SO question.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360