[ https://issues.apache.org/jira/browse/LOG4J2-500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13891975#comment-13891975 ]
Remko Popma commented on LOG4J2-500: ------------------------------------ I may need some help with this... With the current version of trunk, MBeans are not unregistering when a webapp is undeployed. As far as I can tell, the {{LoggerContext.stop()}} method is never called. I've tested on Tomcat 7.0.50 and 8.0.1. I have log4j-api and log4j-core jar files in WEB-INF/lib, and a jsp file that instantiates a {{Logger}} and calls {{logger.info()}} on it. No listeners or anything. Displaying the JSP page in a browser correctly causes the MBeans to get registered. I expected the {{Log4jWebInitializerImpl.deinitialize()}} method to be called, but I don't see the log message {{"Removing LoggerContext for " + this.name + "."}} in the console or in any log file... On the same hand, I also cannot find any _initialization_ log messages. (I expected to see the {{"Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment."}} message somewhere but cannot find it.) > Unloading one webapp unloads JMX MBeans for all webapps > ------------------------------------------------------- > > Key: LOG4J2-500 > URL: https://issues.apache.org/jira/browse/LOG4J2-500 > Project: Log4j 2 > Issue Type: Bug > Components: JMX > Affects Versions: 2.0-rc1 > Reporter: Remko Popma > Assignee: Remko Popma > > As a stopgap solution for LOG4J2-406, all MBeans are unregistered when a > LoggerContext is stopped. > In an application server, multiple web applications can be deployed and > undeployed independently and a better solution would only unregister the > MBeans associated with the web application that is being undeployed. > Current MBean ObjectNames look like this (simplified): > {code} > ...StatusLogger > ...ContextSelector > ...LoggerContext,ctx=%s > ...LoggerConfig,ctx=%s,name=%s > ...Appender,ctx=%s,name=%s > ... > {code} > Assuming that every web application has a unique name, and this name becomes > the name of the LoggerContext, then one solution would be to create > StatusLogger and ContextSelector MBeans that have the LoggerContext name in > their ObjectName: > {code} > ...StatusLogger,ctx=%s > ...ContextSelector,ctx=%s > ...LoggerContext,ctx=%s > ...LoggerConfig,ctx=%s,name=%s > ...Appender,ctx=%s,name=%s > ... > {code} > This way, every web application would have its own StatusLogger and > ContextSelector MBeans. The MBeans may point to the same (shared) underlying > StatusLogger and ContextSelector objects. When a web application is > undeployed, unregistering all MBeans associated with the LoggerContext will > not affect any MBeans associated with another web application (which has it > own, separate, LoggerContext). -- This message was sent by Atlassian JIRA (v6.1.5#6160) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org