Possibly something like that. As I said, I haven’t had a chance to investigate it so I am not sure if interpolation is supported in that exact usage.
I do wonder why you need to do it this way though. Ralph > On Oct 12, 2020, at 9:31 AM, רפי <rafr...@gmail.com> wrote: > > I will try it. > Do you mean that I will use the following: > > %replace{%msg}{LOGLEVEL}$${event:Level} > > ? > > > בתאריך יום ב׳, 12 באוק׳ 2020 ב-18:35 מאת Ralph Goers < > ralph.go...@dslextreme.com>: > >> I suspect that using $${event:Level} could be made to work but I would >> have to try it to see what it would take and right now I have been >> extremely busy with the $dayjob$. >> >> Ralph >> >>> On Oct 12, 2020, at 2:56 AM, רפי <rafr...@gmail.com> wrote: >>> >>> In log4j2 configured by log4j2.xml - how can I replace some text with >>> other conversion >>> pattern? >>> >>> >>> For example, I have some message with the word "LOGLEVEL" and I want to >>> replace it with the current log level (WARN/DEBUG/ERROR/TRACE/INFO). The >>> conversion pattern >>> <https://logging.apache.org/log4j/2.x/manual/layouts.html> for the log >>> level is %p or %level, so I tried this: >>> >>> %replace{%msg}{LOGLEVEL}{%level} >>> >>> But instead of replacing the "LOGLEVEL" text with the actual *level* it >>> just replaced it with the text "%level". >>> >>> *The original message was*: this trace is LOGLEVEL log >>> >>> *For INFO trace I want to get*: this trace is INFO log >>> >>> *But I actually got*: this trace is %level log >>> >>> How can I achieve this requirement? >>> >>> >>> >>> I asked it on StackOverflow but no one knows the answer. >>> >>> >> https://stackoverflow.com/questions/64305649/log4j2-replace-some-text-with-other-log4j2-conversion-pattern-with-level-for >>> >>> >>> >>> Thanks, >>> >>> Refael >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >> For additional commands, e-mail: log4j-user-h...@logging.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org