On Wed, Feb 5, 2020 at 6:14 Volkan Yazıcı <[email protected]> wrote:

> In its current form, JsonTemplateLayout exposes the following
> timestamp accessors:
>
> - timestamp -- string, formatted according to the given
>   timestampFormatPattern)
>
> - timestamp:epoch[:divisor=<divisor>[,integral]] -- double
>   (or long, if "integral" is provided) epoch nanoseconds divided
>   by "divisor", if supplied.
>
> In order to support the current JsonLayout structure,
> JsonTemplateLayout requires a new directive: "nanos fraction of epoch
> seconds". I presume this is an artifact (rather than a feature) of
> JsonLayout, where it got while trying to serialize Instant as is via
> Jackson. There are two potential approaches I can think of to address
> this in JsonTemplateLayout:
>
> 1. Don't do it at all. (My vote goes here!)
>
> 2. Introduce a new directive for "nanos fraction of epoch
>    seconds". This also makes me think: What if somebody
>    would need "nanos fraction of epoch millis" or "millis
>    fraction of epoch seconds", etc.?

I don’t think there’s a danger of people requiring such arbitrary
fractions.

The “nanos fraction of epoch seconds” is taken from the way
java.time.Instant is modeled, which in turn is very close to how
lower-level (operating system) APIs work for very granular timestamps.

If we choose the option to leave out very granular timestamps from the
JsonTemplateLayout I suspect we’ll see a feature request to add it soon.

On the other hand, if this is technically difficult or cumbersome to
implement it could be postponed until we get such a feature request.

>
>
> I've actually directed this question to @Ralph in the PR review[1],
> but got no replies so far. Any comments?
>
> [1] https://github.com/apache/logging-log4j2/pull/335/files#r372016555
>
> On Tue, Jan 28, 2020 at 9:00 PM Volkan Yazıcı <[email protected]>
> wrote:
> >
> > I've just created a PR[1] contributing LogstashLayout to Log4j core.
> > Please see the GitHub link for the feedback/support requests. I will
> > appreciate a quick review cycle, since I will try my best to invest
> > quite some time into this during FOSDEM.
> >
> > [1] https://github.com/apache/logging-log4j2/pull/335
>

Reply via email to