The typical way of using it would be to use log4j-web which hooks a LoggerContext to your ServletConext life cycle. However, since you're using this within what I'm assuming is the same ClassLoader, what you'll need to do is create a custom ContextSelector implementation to choose between your two contexts if they're not determinable just by examining the calling class's ClassLoader.
See info here about extending that: https://logging.apache.org/log4j/2.x/manual/extending.html On Fri, 8 Feb 2019 at 04:35, Joan Balagueró - ventusproxy <joan.balagu...@ventusproxy.com> wrote: > > Hello, > > > > This is a crosspost, already asked in StackOverflow, no success > (https://stackoverflow.com/questions/54535220/how-to-put-working-2-separate- > log4j2-xml-files) > > > > As a briefing, the question would be how we can have 2 log4j2 > configurations working at the same time within the same web application. > > > > The main web app configures a log4j2 using below when it starts (and works): > > System.setProperty("log.dir", dirLogs); > > System.setProperty("log4j.configurationFile", "file://" + servletPath + > "WEB-INF/log4j.xml"); > > this.accessLog = LogManager.getLogger("LOGGER_ACCESS"); > > > > After this, a user can dynamically upload jars that also use log4j. The main > webapp doesn’t know anything about these jars, it just uploads them. This is > one example of a user setting up log4j2 within his webapp: > > System.setProperty("log4j.configurationFile", > "file:///home/ventus/logs/confirms/log4j_confirms.xml"); > confirmLog = LogManager.getLogger("LOGGER_CONFIRM"); > > > > The problem is this second configuration does not work: > > confirmLog = LOGGER_CONFIRM:OFF in AsyncContext@4c23524b > confirmLogClass = org.apache.logging.log4j.core.async.AsyncLogger > > > > > > Is there any way to solve this? I’m probably doing something wrong. > > > > Thanks, > > > > Joan. > -- Matt Sicker <boa...@gmail.com> --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org