So far I have looked at the logstash layout ( https://github.com/vy/log4j2-logstash-layout). It seems it doesn't work properly for my use case.
Basically if I have key,value pairs I log them into the LogEvent message field, then I parse them while generating JSON objects. The key,value pairs are not known in advance; sometimes they are null; If the keys are null, I don't want to log them at all. Are there any other ways to do this? On Thu, Aug 13, 2020 at 3:38 PM Naz S <sn1.naze...@gmail.com> wrote: > Thank you for your swift response, really appreciate it. > > Wondering when the 2.14.0 release will come out? > > On Wed, Aug 12, 2020 at 4:59 PM Ralph Goers <ralph.go...@dslextreme.com> > wrote: > >> JsonTemplateLayout hasn’t been merged to the release-2.x branch but it >> will be so that it can be included in the 2.14.0 release. >> >> Ralph >> >> > On Aug 12, 2020, at 7:47 AM, Carter Kozak <cko...@ckozak.net> wrote: >> > >> > Hi Naz, >> > >> > Volkan has contributed a fantastic json template layout that I expect >> will do what you want, however it has not been released yet. >> > https://github.com/apache/logging-log4j2/pull/335 >> > >> > This discussion from the mailing list provides several options which >> may be relevant to your use case: >> > >> https://lists.apache.org/thread.html/r538bb480c6d92813224b6a207e34210cccebc01e8d1781943d0ce32d%40%3Clog4j-user.logging.apache.org%3E >> > >> >> But my custom json layout doesn't write into a file. Do I have to >> write a file appender for that? >> > >> > Layout implementations can be configured with any appender, the >> existing file based appenders >> > work with custom layouts. The layout is responsible for converting a >> LogEvent into a format (e.g. bytes) that >> > can be written to an appender (file, socket, standard out, etc) without >> being aware of the appenders >> > implementation details. >> > >> > Best, >> > -ck >> > >> > On Wed, Aug 12, 2020, at 09:56, Naz S wrote: >> >> Hi, >> >> >> >> I'm trying to use JSON layout for a logging format. When I use the >> default >> >> JSON Layout, I see that there are some fields which are unnecessary to >> me >> >> (for example, loggerFqcn, endOfBatch, etc). >> >> >> >> Then I decided to implement a custom JSON layout. But I see that >> >> JacksonFactory is not visible outside the package. Now I get only >> necessary >> >> fields from LogEvent and generate JSON format using JSON generator. >> Every >> >> configuration is done by code. But ultimately I want to configure >> fields in >> >> log4j2.xml file. Any suggestions? >> >> >> >> Also I would like to write logs into a log file. But my custom json >> layout >> >> doesn't write into a file. Do I have to write a file appender for that? >> >> >> >> Many thanks, >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >> For additional commands, e-mail: log4j-user-h...@logging.apache.org >> >>