1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.pattern;
15
16 import ch.qos.logback.classic.spi.ILoggingEvent;
17
18
19
20
21
22
23
24
25 public class MicrosecondConverter extends ClassicConverter {
26
27 @Override
28 public String convert(ILoggingEvent event) {
29 int nanos = event.getNanoseconds();
30 int millis_and_micros = nanos / 1000;
31 int micros = millis_and_micros % 1000;
32
33 if (micros >= 100)
34 return Integer.toString(micros);
35 else if (micros >= 10)
36 return "0" + Integer.toString(micros);
37 else
38 return "00" + Integer.toString(micros);
39 }
40
41 }