[ https://issues.apache.org/jira/browse/LOG4J2-3468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pooja Pandey updated LOG4J2-3468: --------------------------------- Description: In my application where I am using custom logger and custom ContextSelector log4j2 2.17.2 version, 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 use standard logger and standard ContextSelector. I have defined below system property as a static block in custom logger. _*static {*_ _*System.setProperty("Log4jContextSelector", "logger.log4j2.CustomLog4j2ContextSelector");*_ _*}*_ 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. Content of file 'log4j2.component.properties' -> _*Log4jContextSelector=logger.log4j2.CustomLog4j2ContextSelector*_ But with this fix, for other 2 wars I get following below harmless error(wars functionality works fine) 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".*_ 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. was: In my application where I am using custom logger and custom ContextSelector log4j2 2.17.2 version, 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. _*static {*_ _*System.setProperty("Log4jContextSelector", "logger.log4j2.CustomLog4j2ContextSelector");*_ _*}*_ 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. Content of file 'log4j2.component.properties' -> _*Log4jContextSelector=logger.log4j2.CustomLog4j2ContextSelector*_ But with this fix, for other 2 wars I get following below harmless error(wars functionality works fine) 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".*_ 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. > can we set log4j property 'Log4jContextSelector' per webapps war deployment > --------------------------------------------------------------------------- > > Key: LOG4J2-3468 > URL: https://issues.apache.org/jira/browse/LOG4J2-3468 > Project: Log4j 2 > Issue Type: Question > Components: Log4j 1.2 bridge > Affects Versions: 2.17.2 > Reporter: Pooja Pandey > Priority: Major > > In my application where I am using custom logger and custom ContextSelector > log4j2 2.17.2 version, 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 use standard logger and standard ContextSelector. > > I have defined below system property as a static block in custom logger. > _*static {*_ > _*System.setProperty("Log4jContextSelector", > "logger.log4j2.CustomLog4j2ContextSelector");*_ > _*}*_ > 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. > > Content of file 'log4j2.component.properties' -> > _*Log4jContextSelector=logger.log4j2.CustomLog4j2ContextSelector*_ > But with this fix, for other 2 wars I get following below harmless error(wars > functionality works fine) 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".*_ > > 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. -- This message was sent by Atlassian Jira (v8.20.1#820001)