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 jingguo yao <ya...@gmail.com> on 2021/09/06 06:02:47 UTC
Is there a way to develop my own resolver for JSON template layout?
https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
lists all the supported resolvers. I want to develop a new resolver. Is
there a way to do this?
--
Jingguo
Re: Is there a way to develop my own resolver for JSON template layout?
Posted by Volkan Yazıcı <vo...@gmail.com>.
I see, it is indeed implemented as a `PatternConverter`. Yet they can still
implement that as a `StrLookup` and use it via "${traceId}" in the JSON
template – both PatternLayout and JsonTemplateLayout can resolve it
accordingly.
On Sun, Sep 19, 2021 at 11:48 PM Ralph Goers <ra...@dslextreme.com>
wrote:
> Volkan,
>
> The syntax is wrong for it to be a lookup. With that syntax it must be a
> PatternConverter.
> You can find the source for it at
> https://github.com/apache/skywalking-java/blob/main/apm-application-toolkit/apm-toolkit-log4j-2.x/src/main/java/org/apache/skywalking/apm/toolkit/log/log4j/v2/x/TraceIdConverter.java,
>
> not that looking at will help you figure out what it actually does.
>
> His request makes sense though. He wants the traceId to show up as an
> individual
> field in the JSON. It would have been better though if SkyWalking had
> provided a
> simple way to inject it into the ThreadContextMap. Then nothing special
> would be needed.
>
> Ralph
>
> > On Sep 19, 2021, at 12:24 PM, Volkan Yazıcı <vo...@gmail.com>
> wrote:
> >
> > This is the first time I have ever heard about SkyWalking, hence
> apologies
> > in advance if I am about to say something nonsense. In the link you have
> > shared, I see that you use the `%traceId` directive in your PatternLayout
> > configuration. Is that a simple Lookup implementation, e.g., extending
> from
> > StrLookup? If so, why not simply use that Lookup in JsonTemplateLayout
> > <
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#faq-lookups
> >
> > too?
> >
> > On Sat, Sep 18, 2021 at 10:26 AM jingguo yao <ya...@gmail.com>
> wrote:
> >
> >> Volkan, I am thinking of the integration of Log4j2 JSON template layout
> >> with SkyWalking. SkyWalking has done the integration with Log4j2 for the
> >> pattern layout:
> >>
> >>
> https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Application-toolkit-log4j-2.x.md
> >> .
> >> With the resolver extending supported, it can be easily done.
> >>
> >>
> >>
> >> On Fri, Sep 17, 2021 at 3:26 PM Volkan Yazıcı <vo...@gmail.com>
> >> wrote:
> >>
> >>> Jingguo, I am curious, what kind of a new resolver do you want to
> >> develop?
> >>> If that is something useful for other users, it is good to ship that in
> >>> Log4j by default.
> >>>
> >>> On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com>
> wrote:
> >>>
> >>>>
> >>>>
> >>>
> >>
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
> >>>> lists all the supported resolvers. I want to develop a new resolver.
> Is
> >>>> there a way to do this?
> >>>>
> >>>> --
> >>>> Jingguo
> >>>>
> >>>
> >>
> >>
> >> --
> >> Jingguo
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
Re: Is there a way to develop my own resolver for JSON template
layout?
Posted by Ralph Goers <ra...@dslextreme.com>.
Volkan,
The syntax is wrong for it to be a lookup. With that syntax it must be a PatternConverter.
You can find the source for it at https://github.com/apache/skywalking-java/blob/main/apm-application-toolkit/apm-toolkit-log4j-2.x/src/main/java/org/apache/skywalking/apm/toolkit/log/log4j/v2/x/TraceIdConverter.java,
not that looking at will help you figure out what it actually does.
His request makes sense though. He wants the traceId to show up as an individual
field in the JSON. It would have been better though if SkyWalking had provided a
simple way to inject it into the ThreadContextMap. Then nothing special would be needed.
Ralph
> On Sep 19, 2021, at 12:24 PM, Volkan Yazıcı <vo...@gmail.com> wrote:
>
> This is the first time I have ever heard about SkyWalking, hence apologies
> in advance if I am about to say something nonsense. In the link you have
> shared, I see that you use the `%traceId` directive in your PatternLayout
> configuration. Is that a simple Lookup implementation, e.g., extending from
> StrLookup? If so, why not simply use that Lookup in JsonTemplateLayout
> <https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#faq-lookups>
> too?
>
> On Sat, Sep 18, 2021 at 10:26 AM jingguo yao <ya...@gmail.com> wrote:
>
>> Volkan, I am thinking of the integration of Log4j2 JSON template layout
>> with SkyWalking. SkyWalking has done the integration with Log4j2 for the
>> pattern layout:
>>
>> https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Application-toolkit-log4j-2.x.md
>> .
>> With the resolver extending supported, it can be easily done.
>>
>>
>>
>> On Fri, Sep 17, 2021 at 3:26 PM Volkan Yazıcı <vo...@gmail.com>
>> wrote:
>>
>>> Jingguo, I am curious, what kind of a new resolver do you want to
>> develop?
>>> If that is something useful for other users, it is good to ship that in
>>> Log4j by default.
>>>
>>> On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com> wrote:
>>>
>>>>
>>>>
>>>
>> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
>>>> lists all the supported resolvers. I want to develop a new resolver. Is
>>>> there a way to do this?
>>>>
>>>> --
>>>> Jingguo
>>>>
>>>
>>
>>
>> --
>> Jingguo
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Is there a way to develop my own resolver for JSON template layout?
Posted by Volkan Yazıcı <vo...@gmail.com>.
This is the first time I have ever heard about SkyWalking, hence apologies
in advance if I am about to say something nonsense. In the link you have
shared, I see that you use the `%traceId` directive in your PatternLayout
configuration. Is that a simple Lookup implementation, e.g., extending from
StrLookup? If so, why not simply use that Lookup in JsonTemplateLayout
<https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#faq-lookups>
too?
On Sat, Sep 18, 2021 at 10:26 AM jingguo yao <ya...@gmail.com> wrote:
> Volkan, I am thinking of the integration of Log4j2 JSON template layout
> with SkyWalking. SkyWalking has done the integration with Log4j2 for the
> pattern layout:
>
> https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Application-toolkit-log4j-2.x.md
> .
> With the resolver extending supported, it can be easily done.
>
>
>
> On Fri, Sep 17, 2021 at 3:26 PM Volkan Yazıcı <vo...@gmail.com>
> wrote:
>
> > Jingguo, I am curious, what kind of a new resolver do you want to
> develop?
> > If that is something useful for other users, it is good to ship that in
> > Log4j by default.
> >
> > On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com> wrote:
> >
> > >
> > >
> >
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
> > > lists all the supported resolvers. I want to develop a new resolver. Is
> > > there a way to do this?
> > >
> > > --
> > > Jingguo
> > >
> >
>
>
> --
> Jingguo
>
Re: Is there a way to develop my own resolver for JSON template layout?
Posted by jingguo yao <ya...@gmail.com>.
Volkan, I am thinking of the integration of Log4j2 JSON template layout
with SkyWalking. SkyWalking has done the integration with Log4j2 for the
pattern layout:
https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Application-toolkit-log4j-2.x.md.
With the resolver extending supported, it can be easily done.
On Fri, Sep 17, 2021 at 3:26 PM Volkan Yazıcı <vo...@gmail.com>
wrote:
> Jingguo, I am curious, what kind of a new resolver do you want to develop?
> If that is something useful for other users, it is good to ship that in
> Log4j by default.
>
> On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com> wrote:
>
> >
> >
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
> > lists all the supported resolvers. I want to develop a new resolver. Is
> > there a way to do this?
> >
> > --
> > Jingguo
> >
>
--
Jingguo
Re: Is there a way to develop my own resolver for JSON template layout?
Posted by Volkan Yazıcı <vo...@gmail.com>.
Jingguo, I am curious, what kind of a new resolver do you want to develop?
If that is something useful for other users, it is good to ship that in
Log4j by default.
On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com> wrote:
>
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
> lists all the supported resolvers. I want to develop a new resolver. Is
> there a way to do this?
>
> --
> Jingguo
>
Re: Is there a way to develop my own resolver for JSON template layout?
Posted by Volkan Yazıcı <vo...@gmail.com>.
Yes, there certainly is, though it is targeted for soon-to-be-released
2.15.0 release.
If using 2.15.0-SNAPSHOT is an option for you, see the Extending section of
the manual
<https://github.com/apache/logging-log4j2/blob/release-2.x/src/site/asciidoc/manual/json-template-layout.adoc.vm#L1529>
.
On Mon, Sep 6, 2021 at 8:03 AM jingguo yao <ya...@gmail.com> wrote:
>
> https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#map-resolver-template
> lists all the supported resolvers. I want to develop a new resolver. Is
> there a way to do this?
>
> --
> Jingguo
>