removed the log4j2.component.properties files and added following to $CATALINA_HOME/bin/setenv.sh (works):export CATALINA_OPTS="$CATALINA_OPTS -Dlog4j2.enableJndiContextSelector=true" export CATALINA_OPTS="$CATALINA_OPTS -DLog4jContextSelector=org.apache.logging.log4j.core.selector.JndiContextSelector"
Arbi Sookazian | Sr Software Engineer | Medata, Inc. 5 Peters Canyon Road, Suite 250 Irvine, CA 92606 asookaz...@medata.com | www.medata.com ----- Original Message ----- From: Arbi Sookazian <asookaz...@medata.com> To: log4j-user@logging.apache.org Sent: Tue, 29 Apr 2025 12:22:56 -0700 (PDT) Subject: Re: Unable to config/init logging separation for web app on Tomcat 7.0.82 body {height: 100%; color:#000000; font-size:12pt; font-family:arial,helvetica,sans-serif;}Strike my previous comment regarding testing1 (it's not configured for separate logging and is likely logging to catalina.out). Any possible reasons why potentially log4j2.component.properties is not being scanned or fail to read key/value pairs in WEB-INF/classes dir? Does it depend on the deployment folder hierarchical structure? This is exploded app like my dev envmt. thanks. Arbi Sookazian | Sr Software Engineer | Medata, Inc. 5 Peters Canyon Road, Suite 250 Irvine, CA 92606 asookaz...@medata.com | www.medata.com ----- Original Message ----- From: Arbi Sookazian <asookaz...@medata.com> To: log4j-user@logging.apache.org Sent: Tue, 29 Apr 2025 12:05:43 -0700 (PDT) Subject: Re: Unable to config/init logging separation for web app on Tomcat 7.0.82 There seems to be an issue with reading from the WEB-INF/classes/log4j2.component.properties file (root cause unknown currently).If I add the following to $CATALINA_HOME/bin/setenv.sh file:export CATALINA_OPTS="$CATALINA_OPTS -DLog4jContextSelector=org.apache.logging.log4j.core.selector.JndiContextSelector"the testing2-catalina.out separated logging file is created and written to as expected in $CATALINA_HOME/logs dir. However, I don't see it being created for testing1-catalina.out which is also configured for separated logging (root cause unknown). Arbi Sookazian | Sr Software Engineer | Medata, Inc. 5 Peters Canyon Road, Suite 250 Irvine, CA 92606 asookaz...@medata.com | www.medata.com ----- Original Message ----- From: Arbi Sookazian <asookaz...@medata.com> To: log4j-user@logging.apache.org Sent: Tue, 29 Apr 2025 08:55:21 -0700 (PDT) Subject: Re: Unable to config/init logging separation for web app on Tomcat 7.0.82 Sorry, just realized a possibly important detail. In dev envmt, I am using slf4j-api-2.0.6.jar, in QA we are using slf4j-api-1.7.25.jar. When log4j2.debug was enabled in previous testing, I see the following logging/notes: DEBUG StatusLogger Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig]. DEBUG StatusLogger createLogger(additivity="false", level="TRACE", name="org.springframework", includeLocation="null", ={LogToRollingFile, Console}, ={}, Configuration(jar:file:/C:/sw/apache-tomcat-7.0.84/webapps/base/WEB-INF/lib/base.jar!/log4j2.xml), Filter=null) DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=66fbd5ea,component=Loggers,name=org.springframework SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier. SLF4J: Ignoring binding found at [jar:file:/C:/sw/apache-tomcat-7.0.84/shared/log4j-slf4j-impl-2.9.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation. I will enable same debug logging and test again. Perhaps the version of the slf4j-api-*.jar needs to be matched/upgraded in QA envmt. The log4j*.jar files are identical in dev and QA $CATALINA_HOME/shared dir: log4j-1.2-api-2.9.1.jar log4j-api-2.9.1.jar log4j-core-2.9.1.jar log4j-jcl-2.9.1.jar log4j-slf4j-impl-2.9.1.jar log4j-web-2.9.1.jar Arbi Sookazian | Sr Software Engineer | Medata, Inc. 5 Peters Canyon Road, Suite 250 Irvine, CA 92606 asookaz...@medata.com | www.medata.com ----- Original Message ----- From: Arbi Sookazian <asookaz...@medata.com> To: log4j-user@logging.apache.org Sent: Tue, 29 Apr 2025 08:22:12 -0700 (PDT) Subject: Unable to config/init logging separation for web app on Tomcat 7.0.82 Hi, I have been able to successfully configure and log separately for multiple web apps deployed to same Tomcat 7.0.84 container in dev environment (Windows 11 w/ cygwin). Now trying to do the same testing in QA environment with Tomcat 7.0.82 (Linux) and having issue below at startup. I doubt it has anything to do with differing OS. Please advise what is wrong or is it possibly a JAR mismatch in $CATALINA_HOME/shared dir wrt log4j-*.jar files or slf4j-*.jar files between the two environments. log4j-web-2.9.1.jar is in shared dir. Thanks. INFO: Deploying web application directory /opt/apache/testing-apache-tomcat-7.0.82/webapps/testing2DEBUG StatusLogger Log4jServletContextListener ensuring that Log4j starts up properly. DEBUG StatusLogger getConfigURI found resource [jndi:/localhost/testing2/WEB-INF/classes/log4j2.xml] in servletContext at [./WEB-INF/classes/log4j2.xml] WARN StatusLogger Potential problem: Selector is not an instance of NamedContextSelector. We have double checked the configs in web.xml and the log4j2.xml as well as log4j2.component.properties. Everything looks correct/expected in the QA setup. Contents of log4j2.component.properties: log4j2.enableJndiContextSelector=true Log4jContextSelector=org.apache.logging.log4j.core.selector.JndiContextSelector Contents of web.xml added snippet (added above <listener> section): <context-param> <param-name>isLog4jAutoInitializationDisabled</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>isLog4jContextSelectorNamed</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>log4jContextName</param-name> <param-value>testing2</param-value> </context-param> <context-param> <param-name>log4jConfiguration</param-name> <param-value>./WEB-INF/classes/log4j2.xml</param-value> </context-param> <env-entry> <env-entry-name>log4j/context-name</env-entry-name> <env-entry-value>testing2</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> <listener> <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class> </listener> <filter> <filter-name>log4jServletFilter</filter-name> <filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class> </filter> <filter-mapping> <filter-name>log4jServletFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> Arbi Sookazian | Sr Software Engineer | Medata, Inc. 5 Peters Canyon Road, Suite 250 Irvine, CA 92606 asookaz...@medata.com | www.medata.com