You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Volkan Yazıcı <vo...@yazi.ci> on 2021/11/01 08:20:50 UTC

Re: Question regarding JSON Template timestamp rendering

Thanks so much for confirming the fix and more importantly, sparing time to
share the issue with us. 2.15.0 is supposed to be released soon. We are
waiting for some changes from another maintainer (I am looking at you
Ralph) and then we will be done.

What I would really appreciate is some details about your use case. How do
you purpose JTL? What do you use for the log storage engine? ELK? Which
appender (pipeline?) do you use to make your way from the application to
your long sink? What is the scale? Do you have any Log4j/JTL customizations?

And... Thanks for your kind words. Flu has shackled me to bed for a couple
of days, but I am feeling better now.

On Thu, Oct 28, 2021 at 8:28 PM Andrew Harris (andharr2) <
andrew.harris@appdynamics.com> wrote:

> Volkan,
>
> I am happy to report that the change in
> 2dd7063fb6c6fe73070aded6607a2e2d53613b46 appears to have resolved the
> issue! After building and installing a local snapshot of
> log4j-layout-template-json from release-2.x, I now see the following in my
> test application:
>
> ```
> {"timestamp.epoch":1635443515353213000,"timestamp.iso8601":"2021-10-28T17:51:55.353Z","severityText":"INFO","body":"Starting
> count"}
> {"timestamp.epoch":1635443515360647000,"timestamp.iso8601":"2021-10-28T17:51:55.360Z","severityText":"INFO","body":"Event
> 0"}
> {"timestamp.epoch":1635443516365136000,"timestamp.iso8601":"2021-10-28T17:51:56.365Z","severityText":"INFO","body":"Event
> 1"}
> {"timestamp.epoch":1635443517365604000,"timestamp.iso8601":"2021-10-28T17:51:57.365Z","severityText":"INFO","body":"Event
> 2"}
> ```
>
> After several more runs, including runs over SLF4J, the epoch timestamp
> resolver operates as expected. I am also happy to report that a pattern
> layout also continues to operate as expected.
>
> Speaking to the test added in 2dd7063f, I ran exactly that test against
> the previous head b6774209, and indeed the test fails. Also a good sign,
> the test seems to cover the logging behavior! Seen as follows:
>
> ```
> [ERROR] Failures:
> [ERROR]
>  TimestampResolverTest.epoch_nanos_should_not_overlap:43->lambda$epoch_nanos_should_not_overlap$1:69
> Found duplicate(s):
>   [1635444597296722000L]
> in:
>   [1635444597296722000L,
>     1635444597296722000L,
>     1635444597296722000L,
>     1635444597296722000L,
>     1635444597296722000L]
> ```
>
> Meanwhile, of course, the test passes in 2dd7063f.
>
> Thank you for your help here. I am sorry that I wasn't able to isolate the
> issue more quickly, let alone provide a test case myself. Looking forward
> to this change arriving in a future release. Hope you are feeling better,
> too!
>
> Andrew
>

Re: Question regarding JSON Template timestamp rendering

Posted by "Andrew Harris (andharr2)" <an...@appdynamics.com>.
​Volkan,

Happy to hear that you have recovered! Thank you also for the info on the 2.15.0 release, I'm looking forward to it for several reasons.

I'll try to answer your questions:

> How do you purpose JTL?
My organization is looking to standardize application logging across our platform. Our goal is to reduce the internal overhead of monitoring, searching, and sense-making with logs. As an early pass toward this, we have developed an application-based log config using Log4j JTL, that conforms to a standard model.

> What do you use for the log storage engine? ELK?
Splunk is the storage engine that I use most often.

> Which appender (pipeline?) do you use to make your way from the application to your log sink?
My main development work for logging right now is on containerized applications, so stdout and the ConsoleAppender are what I use. All stdout logs forward to our aggregators. This follows current Kubernetes guidance that containers should write logs to stdout, for instance.

> What is the scale?
I hope it's enough to say: we run applications of varying sizes and request volumes in a large-enterprise, service-oriented, cloud-based, containerized architecture. We plan to support thousands of containerized application instances using this standard log format, to include Java applications.

> Do you have any Log4j/JTL customizations?
Yes, a couple at the moment. To support a numeric field derived from an existing Resolver, we wrote a simple custom Lookup that roughly translates the Resolver's output. The Lookup isn't perfect, because it exclusively renders as a String and the desired value is numeric, and because the mapping between the existing Resolver and the desired value is not 1:1. I would like to rewrite this translation as a custom Resolver in Log4j 2.15.0, to render the value correctly as numeric, to avoid the garbage hit of the Lookup, and maybe to provide additional data.

I also would like to implement a custom Resolver to render several nested JSON fields. Right now, we render these nested fields from a combination of fixed environment variable Lookups and the MDC Resolver. We have a regular expression with a simple negative lookahead regex on the MDC Resolver to avoid duplicating MDC values that are rendered elsewhere. It would be nice to simplify these assumptions down to one or two custom Resolvers, which could be dropped in much like the current MDC resolver. I also might have a use-case for the Log4j Kubernetes Lookup in the near future.

I hope these responses help. Happy to talk in greater detail as well. Thank you!

Andrew