You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Pooja Pandey <Po...@asg.com.INVALID> on 2022/04/06 13:34:25 UTC

can we set log4j property 'Log4jContextSelector' per webapps war

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

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

Posted by "Piotr P. Karwasz" <pi...@gmail.com>.
Hi Ralph,

On Thu, 7 Apr 2022 at 07:50, Ralph Goers <ra...@dslextreme.com> wrote:
> Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

If there is no `log4j-api` in the web app classpath, I would refrain
from adding a `log4j2.component.properties` to that application.

Currently most components use a single `PropertiesUtil` instance, that
is created when `log4j-api` is first initialized. If multiple
applications are using the same `log4j-api` the
`log4j.component.properties` files contained in all but the first
application will be ignored.

That is why I would propose to remove thread context classloader
support from `PropertiesUtil` in future 2.x releases or check all the
call sites of `PropertiesUtil.getProperties()` to see if they need
application specific properties or not. Of course in 3.x your
properties enhancement proposal solves most problems.

Piotr

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
First, I do not know why you are still using a custom Logger since we already advised you not to do that.

Currently we are using log4j1.x bridge and with that few features don't work with standard logger, though these features might work fine with direct log4j2 logger but we are not sure yet. we have not planned yet to completely migrate to log4j2 interface due to time constraints and to avoid lot of unknown issues with our huge legacy code.

-----Original Message-----
From: Pooja Pandey <Po...@asg.com.INVALID> 
Sent: Thursday, April 7, 2022 2:16 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: RE: can we set log4j property 'Log4jContextSelector' per webapps war

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


-> I asked where the jars are located. You replied "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.”  That answer implies that they are not in WEB-INF/lib of any of the web apps.


We needed log4j2 jars in soa-dir/lib since these log4j jars are required by one more process other than my webapps wars process. My webapps war doesn't contain log4j*.jar. However other 2 jars are being fetched from artifactory and those wars already contain log4j2 jars.


-> Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

This could not fix the issue earlier, I would try again putting it various places in webapps war file.

-----Original Message-----
From: Ralph Goers <ra...@dslextreme.com>
Sent: Thursday, April 7, 2022 11:21 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: can we set log4j property 'Log4jContextSelector' per webapps war

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


I asked where the jars are located. You replied "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.”  That answer implies that they are not in WEB-INF/lib of any of the web apps.

First, I do not know why you are still using a custom Logger since we already advised you not to do that.

Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

Ralph

> On Apr 6, 2022, at 3:25 PM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>
> But these other 2 wars already have log4j2 jars bundled with these. I mean in WEB-INF/lib of these wars, log4j2 jars are available and even the version is also different which is log4j2 2.17.1 while my application is using 2.17.2.
>
> Get Outlook for iOS<https://aka.ms/o0ukef> 
> ________________________________
> From: Ralph Goers <ra...@dslextreme.com>
> Sent: Wednesday, April 6, 2022 11:54:26 PM
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: Re: can we set log4j property 'Log4jContextSelector' per 
> webapps war
>
> *** External email: Verify sender before opening attachments or links
> ***
>
>
> OK. If all 3 wars are using the same Log4j jars then you can only have a single ContextSelector.
>
> Ralph
>
>> On Apr 6, 2022, at 11:17 AM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>>
>> 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 <ra...@dslextreme.com>
>> Sent: Wednesday, April 6, 2022 11:33:55 PM
>> To: Log4J Users List <lo...@logging.apache.org>
>> 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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

B KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB  [  X  ܚX KK[XZ[
    ]\ \ ][  X  ܚX P   [ ˘\X K ܙ B  ܈Y][ۘ[  [X[  K[XZ[
    ]\ \ Z[   [ ˘\X K ܙ B 

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

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
-> I asked where the jars are located. You replied "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.”  That answer implies that they are not in WEB-INF/lib of any of the web apps.


We needed log4j2 jars in soa-dir/lib since these log4j jars are required by one more process other than my webapps wars process. My webapps war doesn't contain log4j*.jar. However other 2 jars are being fetched from artifactory and those wars already contain log4j2 jars.


-> Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

This could not fix the issue earlier, I would try again putting it various places in webapps war file.

-----Original Message-----
From: Ralph Goers <ra...@dslextreme.com> 
Sent: Thursday, April 7, 2022 11:21 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: can we set log4j property 'Log4jContextSelector' per webapps war

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


I asked where the jars are located. You replied "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.”  That answer implies that they are not in WEB-INF/lib of any of the web apps.

First, I do not know why you are still using a custom Logger since we already advised you not to do that.

Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

Ralph

> On Apr 6, 2022, at 3:25 PM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>
> But these other 2 wars already have log4j2 jars bundled with these. I mean in WEB-INF/lib of these wars, log4j2 jars are available and even the version is also different which is log4j2 2.17.1 while my application is using 2.17.2.
>
> Get Outlook for iOS<https://aka.ms/o0ukef> 
> ________________________________
> From: Ralph Goers <ra...@dslextreme.com>
> Sent: Wednesday, April 6, 2022 11:54:26 PM
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: Re: can we set log4j property 'Log4jContextSelector' per 
> webapps war
>
> *** External email: Verify sender before opening attachments or links 
> ***
>
>
> OK. If all 3 wars are using the same Log4j jars then you can only have a single ContextSelector.
>
> Ralph
>
>> On Apr 6, 2022, at 11:17 AM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>>
>> 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 <ra...@dslextreme.com>
>> Sent: Wednesday, April 6, 2022 11:33:55 PM
>> To: Log4J Users List <lo...@logging.apache.org>
>> 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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Ralph Goers <ra...@dslextreme.com>.
I asked where the jars are located. You replied "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.”  That answer implies that they are not in WEB-INF/lib of any of the web apps.

First, I do not know why you are still using a custom Logger since we already advised you not to do that.

Second, putting the property in log4j2.component.properties is correct. However, it must only be on the classpath of the web app that needs it, not in a shared directory.

Ralph

> On Apr 6, 2022, at 3:25 PM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
> 
> But these other 2 wars already have log4j2 jars bundled with these. I mean in WEB-INF/lib of these wars, log4j2 jars are available and even the version is also different which is log4j2 2.17.1 while my application is using 2.17.2.
> 
> Get Outlook for iOS<https://aka.ms/o0ukef>
> ________________________________
> From: Ralph Goers <ra...@dslextreme.com>
> Sent: Wednesday, April 6, 2022 11:54:26 PM
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: Re: can we set log4j property 'Log4jContextSelector' per webapps war
> 
> *** External email: Verify sender before opening attachments or links ***
> 
> 
> OK. If all 3 wars are using the same Log4j jars then you can only have a single ContextSelector.
> 
> Ralph
> 
>> On Apr 6, 2022, at 11:17 AM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>> 
>> 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 <ra...@dslextreme.com>
>> Sent: Wednesday, April 6, 2022 11:33:55 PM
>> To: Log4J Users List <lo...@logging.apache.org>
>> 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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
But these other 2 wars already have log4j2 jars bundled with these. I mean in WEB-INF/lib of these wars, log4j2 jars are available and even the version is also different which is log4j2 2.17.1 while my application is using 2.17.2.

Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Ralph Goers <ra...@dslextreme.com>
Sent: Wednesday, April 6, 2022 11:54:26 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: can we set log4j property 'Log4jContextSelector' per webapps war

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


OK. If all 3 wars are using the same Log4j jars then you can only have a single ContextSelector.

Ralph

> On Apr 6, 2022, at 11:17 AM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
>
> 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 <ra...@dslextreme.com>
> Sent: Wednesday, April 6, 2022 11:33:55 PM
> To: Log4J Users List <lo...@logging.apache.org>
> 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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Ralph Goers <ra...@dslextreme.com>.
OK. If all 3 wars are using the same Log4j jars then you can only have a single ContextSelector.

Ralph

> On Apr 6, 2022, at 11:17 AM, Pooja Pandey <Po...@asg.com.INVALID> wrote:
> 
> 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 <ra...@dslextreme.com>
> Sent: Wednesday, April 6, 2022 11:33:55 PM
> To: Log4J Users List <lo...@logging.apache.org>
> 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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
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 <ra...@dslextreme.com>
Sent: Wednesday, April 6, 2022 11:33:55 PM
To: Log4J Users List <lo...@logging.apache.org>
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 <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Ralph Goers <ra...@dslextreme.com>.
Where are the Log4j jars located?

Ralph

> On Apr 6, 2022, at 6:34 AM, Pooja Pandey <Po...@asg.com.INVALID> 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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


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

Posted by Matt Sicker <bo...@gmail.com>.
You could try out the JndiContextSelector for this use case as it’s all hosted in the same container server.

—
Matt Sicker

> On Apr 6, 2022, at 08:41, Pooja Pandey <Po...@asg.com.invalid> wrote:
> 
> For other 2 wars I get following harmless error when I keep 'log4j2.component.properties' file on log4j jars class path, to fix class cast exception which I was getting earlier during deployment of my war file.
> 
> ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default.
> 
> "java.lang.ClassCastException: Cannot cast logger.log4j2.CustomLog4j2ContextSelector to org.apache.logging.log4j.core.selector.ContextSelector".
> 
> -----Original Message-----
> From: Pooja Pandey <Po...@asg.com.INVALID> 
> Sent: Wednesday, April 6, 2022 7:04 PM
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: can we set log4j property 'Log4jContextSelector' per webapps war
> 
> *** External email: Verify sender before opening attachments or links ***
> 
> 
> 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: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 

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

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
For other 2 wars I get following harmless error when I keep 'log4j2.component.properties' file on log4j jars class path, to fix class cast exception which I was getting earlier during deployment of my war file.

ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default.

"java.lang.ClassCastException: Cannot cast logger.log4j2.CustomLog4j2ContextSelector to org.apache.logging.log4j.core.selector.ContextSelector".

-----Original Message-----
From: Pooja Pandey <Po...@asg.com.INVALID> 
Sent: Wednesday, April 6, 2022 7:04 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: can we set log4j property 'Log4jContextSelector' per webapps war

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


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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org