Re: can we set log4j property 'Log4jContextSelector' per webapps war

Pooja Pandey <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <MW4PR02MB7220988D8479203872882CF392E79@MW4PR02MB7220.namprd02.prod.outlook.com>
Webapps wars path is like: installation directory/soa-dir/webapps/

Along with various other product libs, log4j2 jars and log4j2 propertie file are placed under soa-dir/lib. This path is accessible by all 3 wars. I cannot make any changes in 2 wars which we are fetching from artifactory.



Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Ralph Goers <[email protected]>
Sent: Wednesday, April 6, 2022 11:33:55 PM
To: Log4J Users List <[email protected]>
Subject: Re: can we set log4j property 'Log4jContextSelector' per webapps war

*** External email: Verify sender before opening attachments or links ***


Where are the Log4j jars located?

Ralph

> On Apr 6, 2022, at 6:34 AM, Pooja Pandey <[email protected]> wrote:
>
> Hi,
>
> In my application, I have 2 processes running and there are 3 webapps war files which get deployed in tomcat version 9.0.60. Out of these 3 war files, one war file is internal to my application while other 2 are coming as final artifacts from artifiactory.
>
> My war uses a custom logger and custom ContextSelector, however other 2 wars from artifactory uses standard logger and standard ContextSelector.
>
> I have defined below system property as a static block in custom logger, however for some unknown reason when my war gets deployed this log4j jars don't find this property and leads to ClassCastException "java.lang.ClassCastException: org.apache.logging.log4j.core.selector.ContextSelector cannot be cast to logger.log4j2.CustomLog4j2ContextSelector". To fix this I have placed 'log4j2.component.properties' file on log4j jars class path, but with this fix, following harmless error get logged for other 2 wars "java.lang.ClassCastException: Cannot cast logger.log4j2.CustomLog4j2ContextSelector to org.apache.logging.log4j.core.selector.ContextSelector".
>
> I am looking for help to come up with a solution where, when my war gets deployed then custom logger context "logger.log4j2.CustomLog4j2ContextSelector" should be used while when other 2 wars get deployed then  "org.apache.logging.log4j.core.selector.ContextSelector" should be used. Please let me know if you have any idea on this.
>
> static {
>    System.setProperty("Log4jContextSelector", "logger.log4j2.CustomLog4j2ContextSelector");
> }
>
>
> Content of file 'log4j2.component.properties' ->
> Log4jContextSelector=logger.log4j2.CustomLog4j2ContextSelector


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
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.