Hi Ralph,

Thank you for the answers.

--Ganapati

On Wed, Nov 16, 2022 at 9:26 PM Ralph Goers <ralph.go...@dslextreme.com>
wrote:

> 1. We need to mark JsonLayout as deprecated. We no longer recommend using
> it. Use JsonTemplateLayout instead.
> 2. The only consideration for JsonTemplateLayout is that you format the
> template correctly.
>
> FWIW, my employer has been using JsonTemplateLayout to log to ELK for
> quite a while now without any problems. Note that you can still use a
> pattern to format the message. This works very well. As you can see by the
> example below you can even include variables to add extra variables to be
> logged from the ThreadContextMap via overrides.
>
> {
>   "@timestamp": {
>     "$resolver": "timestamp",
>     "pattern": {
>       "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
>       "timeZone": "UTC"
>     }
>   },
>   "ecs.version": "1.11.0",
>   "log.level": {
>     "$resolver": "level",
>     "field": "name"
>   },
>   "application": "\${lower:\${spring:spring.application.name}}",
>   "short_message": {
>     "$resolver": "message",
>     "stringified": true
>   },
>   "message": {
>     "$resolver": "pattern",
>     "pattern": "[%t] %X{requestId, sessionId, loginId,  ipAddress,
> accountNumber, \${extraContextVars}} %C{1.}.%M:%L - %m%n"
>   },
>   "process.thread.name": {
>     "$resolver": "thread",
>     "field": "name"
>   },
>   "log.logger": {
>     "$resolver": "logger",
>     "field": "name"
>   },
>   "event.action": {
>     "$resolver": "marker",
>     "field": "name"
>   },
>   "event.data": {
>     "$resolver": "map",
>     "stringified": true
>   },
>   "labels": {
>     "$resolver": "mdc",
>     "flatten": true,
>     "stringified": true,
>     "pattern": "(?!(?i:token)).+"
>   },
>   "tags": {
>     "$resolver": "ndc"
>   },
>   "error.type": {
>     "$resolver": "exception",
>     "field": "className"
>   },
>   "error.message": {
>     "$resolver": "exception",
>     "field": "message"
>   },
>   "error.stack_trace": {
>     "$resolver": "exception",
>     "field": "stackTrace",
>     "stackTrace": {
>       "stringified": true
>     }
>   }
> }
>
>
> Ralph
>
> > On Nov 16, 2022, at 3:54 AM, Ganapathi Vara Prasad <
> ganapathibasamse...@gmail.com> wrote:
> >
> > Hello Team,
> >
> > Our log4j2 configuration uses *PatternLayout* and we are exploring
> > switching to JsonLayout for simplifying integration with ELK. I am trying
> > to find any performance comparison between pattern and json layouts but
> > couldn't find any. I could find only the JsonTemplateLayout benchmark in
> > the log4j-perf module.
> >
> > I wanted to know:
> >
> >   - Is it a reasonable thing to compare the performance of these two
> >   layouts?
> >   - Are there any existing resources comparing the performance of these
> >   two layouts?
> >   - What considerations should we make if we switch to
> JsonTemplateLayout?
> >
> > Thank you for the help.
> >
> > --Ganapati
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>

Reply via email to