I am really not all that clear on what your setup is. A typical Tomcat setup would have a ClassLoader for Tomcat and a ClassLoader for each web application. These web applications each have multiple jars & packages and work fine.
I am not clear what the “main package” is. When you say “single class loader per application” what does it do when it isn’t in that mode? Log4j 2 uses ContextSelectors to locate the LoggerContext. The default in Log4j 2 is the ClassLoaderContextSelector, which works nicely with Tomcat as each ClassLoader will have its own LoggerContext (and thus, its own configuration). You can look at https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector <https://logging.apache.org/log4j/2.x/manual/extending.html#ContextSelector> for the other options that are available. If Websphere needs something else it is possible a new ContextSelector could be created but we would either need the requirements for how it should work or a PR. The ContextSelector used is controlled via the createContextSelector method in Log4jContextFactory. Ralph > On Mar 2, 2022, at 10:11 AM, Markos, Alazar A > <[email protected]> wrote: > > When working with applications which have multiple jars/packages, logging > stops after upgrading to Log4j 2.17.1. Only the main package where the app is > initialized is logging. It seems to be a class loader issue. To resolve > this, we had to go into the deployed jar in websphere and change WAR class > loader policy to single class loader for application. After that, we could > see all the logs from all the jars. Is there a workaround to this issue? It > seems to be consistent across multiple applications. Some feedback would > really help, thanks! > > Alazar Markos > Delta Air Lines > Associate IT Developer > 678-614-0234 > [email protected] <mailto:[email protected]>
