According to http://logging.apache.org/log4j/2.x/manual/webapp.html, Log4j2 should work with Tomcat7.0.47. I'm using TomEE Plus 7.0.47.
I have a webapplication deployed with a log4j2.xml in my web-inf/classes folder. This is the config:
I have a logger declared in a class with name org.alex.util.JSON:
private static final Logger LOG = LoggerFactory.getLogger(JSON.class);
I'm using slf4j-api 1.7.5, and have the following libs added to the tomcat lib:
If I change the Configuration status to TRACE, I can see my configuration file being picked up and configuration happens as expected. Also I can see the MBeans being added.
However, there's not one logging statement ending up in my logfile (although the file is created). I debugged into the log4j2 Logger, and see that the isEnabled(...) method return false because the logger (com.alex.util.JSON) has the level "ERROR" set, while the configuration set the package org.alex to TRACE.
Further investigation shows it uses a DefaultConfiguration configured for level=ERROR, and only root is configured.
Furthermore I noticed that the classloader for the instance of my logger that is created at configuration is org.apache.openejb.core.TempClassLoader, while the classloader of the Logger that is invoked is org.apache.catalina.loader.StandardClassLoader. I don't know enough of the whole mechanism to judge whether or not this is to be expected