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 
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 

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 {

Content of file 'log4j2.component.properties' ->

Reply via email to