0

I want output date time : 2017/12/25 12:55:01.412 -> 2017/12/25 12:55:01.41

%d{yyyy/MM/dd HH:mm:ss.SS} not working.

I'm using log4j-1.2.17

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

In Log4j 2, you can use %maxLen to remove the last millisecond digit:

%maxLen{%d{yyyy/MM/dd HH:mm:ss.SSS}}{22}
Andreas
  • 154,647
  • 11
  • 152
  • 247
  • Sorry, I'm using log4j-1.2.17 – Sơn Việt Dec 25 '17 at 07:26
  • @SơnViệt Any reason you cannot upgrade to Log4j 2? Log4j 1.2 is already more than 2 years past its end-of-life, and Log4j 1.2.17 is more than 5 years old. – Andreas Dec 25 '17 at 14:55
  • Thank for your response, i know Log4j1.x EOL. but request from my customer. So, my system must using Log4j1.x. – Sơn Việt Dec 26 '17 at 04:27
  • @SơnViệt If they are insisting on Log4j 1.2, then they are responsible for the log files, not you, and they get to live with the limitations of the old version. Log4j 1.2 cannot output timestamp with only 2 fractional digits of precision for the seconds. They can get 0 (seconds) or 3 (milliseconds) digits of precision. That's it. – Andreas Dec 26 '17 at 06:26
  • Thankyou! I understand. – Sơn Việt Dec 27 '17 at 14:31