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 public class RelativeTimeConverter extends ClassicConverter {
19
20 long lastTimestamp = -1;
21 String timesmapCache = null;
22
23 public String convert(ILoggingEvent event) {
24 long now = event.getTimeStamp();
25
26 synchronized (this) {
27
28 if (now != lastTimestamp) {
29 lastTimestamp = now;
30 timesmapCache = Long.toString(now - event.getLoggerContextVO().getBirthTime());
31 }
32 return timesmapCache;
33 }
34 }
35 }