Re: log pattern - servlet context name with fallback on pid

Volkan Yazıcı <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CAP7pH7s9f=E8YteFupBjPjj9qRzNwa8MnNL_x_7848_mpjASqA@mail.gmail.com>
Hello Clement,

I am not an expert on *PatternLayout* and lookups, but I think I have a
hypothesis about what is going wrong and how you can fix it.

*${web:servletContextName:-${sys:user.name <http://user.name>}}* lookup
works, because the substitute is again a *lookup*. Though
*${web:servletContextName:-%pid}* lookup doesn't work, because the
substitute is a *pattern*. I think the following would do the trick:
*%equals{${web:servletContextName}}{}{%pid}*. Would you mind checking,
please?

Kind regards.

On Thu, Mar 25, 2021 at 2:32 AM Clément Guillaume <[email protected]>
wrote:

> Hello,
>
> I'm trying to make a log pattern showing the servlet context name or, if
> missing, showing the process id.
>
> ${web:servletContextName} %msg
> works well for servlet context name alone.
>
> %pid %msg
> works well for process id alone.
>
> ${web:servletContextName:-${sys:user.name}} %msg
> works well for servlet context name with fallback to username system
> property ,
>
> ${web:servletContextName:-%pid} %msg
> does work for servlet context name with fallback to process id.
>
> Am I missing something in my pattern?
>
> Thank you
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.