Re: Unable to locate plugin type for Custom log4j2 Appender

Volkan Yazıcı <[email protected]> Wed, 14 Aug 2024 10:23:23 +0200
Newsgroups gmane.comp.apache.logging.log4net.devel,gmane.comp.jakarta.log4j.user
Message-ID <CABDM8gA6_VUXTaU_npe1TVcVdPq8Q69m1PZUjkpMmZWeukki7w@mail.gmail.com>
--000000000000af914f061fa070c6
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks for bringing this to our attention, Piotr.

[See my comments inline below.]

On Tue, Aug 13, 2024 at 8:52=E2=80=AFPM Piotr P. Karwasz <piotr.karwasz@gma=
il.com>
wrote:

> There is no special reason why `JsonTemplateLayout` does not support
> pretty print. It was simply never implemented.
>

See my response to Amanda
<https://lists.apache.org/thread/zz26313jbbz495qnokkwqjkwpos2llp7>, there
are good reasons for not doing it. For one, we first need to start with
answering "Why shall we do it?". If we hear a compelling use case, it is
still technically not trivial due to `JsonWriter#writeRawString()` methods.
Putting that detail aside, I am in favor of guiding users to choose the
right tool for the right job, instead of trying to make every tool cater
for all jobs.


> This could be easily generalized
> (probably in `3.x`) by replacing `JsonWriter` with an interface, to
> support multiple serialization formats. There is already a JIRA issue
> for that (see LOG4J2-3082[0]).
>

Making `JsonWriter` pluggable can indeed be a nice feature. It can even be
served in Log4j 2 without breaking backward compatibility. But it is a
pretty big undertaking. My suggestion is to implement a small enhancement
that is simpler: falling back to an external serializer (e.g., Jackson) for
unknown types. We can easily ship this in Log4j 2 and it addresses the use
case stated in LOG4J2-3082
<https://issues.apache.org/jira/browse/LOG4J2-3082>.


> Admittedly this requires quite some work, but it is within the grasp
> of a semester-long student project or Google Summer of Code.


> If you are willing to contribute such a feature, we can always assist
> you with the Log4j-related details.
>

I am not inclined to support pretty-printing in JTL, but I would
completely support an initiative for enhancing `JsonWriter` with a fallback
serializer to address LOG4J2-3082.

--000000000000af914f061fa070c6--