filebeat推送给o2的毫秒级顺序是乱的
当然这是一个假的microseconds,linux并不支持这个时间级别
- 编写一个微秒转换器
public class LogbackMicrosecondsConverter extends ClassicConverter {
private final long start = System.nanoTime();
@Override
public String convert(ILoggingEvent iLoggingEvent) {
long now = System.nanoTime();
var diffMicroseconds = (now - start)/1000;
var diffStr = String.valueOf(diffMicroseconds);
return diffStr.substring(diffStr.length()-3);
}
}
- 在xml里配置
<conversionRule conversionWord="microseconds"
converterClass="xxx.xxx.LogbackMicrosecondsConverter" />
<property name="CONSOLE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS}%-3microseconds />
- 虽然这是一个假的微秒,但足以解决日志乱续的问题