There may be other ways to do this, but if the classes in the sharedLib are in a specific package, you could configure the log4j2.xml configurations for both web apps to create a separate appender (and a separate log file) for the loggers for that package.
Remko On Sat, Jul 23, 2016 at 3:18 AM, Bill Okara <billok...@gmail.com> wrote: > Hi, > > Following is my deployment env: > > tomcat7 > |- lib/sharedLib12.jar // shared lib used by webapp1 and webapp2 > |- lib/slf4j-api-1.7.7.jar, log4j-api-2.3.jar, log4j-core-2.3.jar, > log4j-slf4j-impl-2.3.jar > | > |- webapps > |-webapp1/WEB-INF/classes/log4j2.xml > | lib/log4j-web-2.3.jar > |-webapp2/WEB-INF/classes/log4j2.xml > | lib/log4j-web-2.3.jar > > > With servlet 3.0+ and default ClassLoaderContextSelector, it was > quite simple (awesome!) to config so that log output from each webapp > will be sent to it's own log file (webapp1.log, webapp2.log) > > But the problem is that log output from the sharedLib jar will always > goto to the first loaded webapp, because: > ----------> Parent Classloader: > org.apache.catalina.loader.StandardClassLoader@59717824 > > the parent classloader (the one sharedLib is loaded) will be assigned > to the loggerContext of the first loaded webapp (which kinda makes > sense). > > > Question: > is there a way to config so that jars inside the tomcat/lib can be > logged to a common/separate logger context (or log file) that is > independent of the loaded webapp? (without configure tomcat to use > log4j2 as internal logger?) > > > Thanks! > Bill > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > >