[logback-dev] [JIRA] (LOGBACK-1374) Increase timestamp resolution

QOS.CH (JIRA) noreply-jira at qos.ch
Sun Jan 21 18:17:00 CET 2018


Oleksandr Gavenko created LOGBACK-1374:
------------------------------------------

             Summary: Increase timestamp resolution
                 Key: LOGBACK-1374
                 URL: https://jira.qos.ch/browse/LOGBACK-1374
             Project: logback
          Issue Type: New Feature
          Components: logback-core
    Affects Versions: 1.2.3
            Reporter: Oleksandr Gavenko
            Assignee: Logback dev list


ILoggingEvent interface assumes that [getTimeStamp|https://logback.qos.ch/apidocs/src-html/ch/qos/logback/classic/spi/ILoggingEvent.html#line.83]() is in milliseconds.

 

Elasticsearch @timestamp resolution is in milliseconds too, see https://github.com/elastic/elasticsearch/issues/10005

 

As workaround people store second fraction in separate field in ES.

 

When sorting by @timestamp in ES events are ordered randomly within millisecond. In contract writing to file at any precision preserves ordering.

 

Is it possible to increase timestamp resolution?

 

With current hardware nanosecond resolution is pretty good.

 

DETAILS:

 

We collect log events into Elasticsearch with project that writes timestamp via:

[https://github.com/internetitem/logback-elasticsearch-appender/blob/master/src/main/java/com/internetitem/logback/elasticsearch/AbstractElasticsearchPublisher.java]

 

   protected static String getTimestamp(long timestamp) \{
       return DATE_FORMAT.get().format(new Date(timestamp));
   }

 

[https://github.com/internetitem/logback-elasticsearch-appender/blob/master/src/main/java/com/internetitem/logback/elasticsearch/ClassicElasticsearchPublisher.java]

 

    public class ClassicElasticsearchPublisher extends AbstractElasticsearchPublisher<ILoggingEvent> \{

        @Override
        protected void serializeCommonFields(JsonGenerator gen, ILoggingEvent event) throws IOException \{
            gen.writeObjectField("@timestamp", getTimestamp(event.getTimeStamp()));

 

Only by changing ILoggingEvent or by providing alternative interface it would be possible to preserve timestamp in better resolution.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list