[ 
https://issues.apache.org/jira/browse/LOG4J2-909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14966647#comment-14966647
 ] 

Remko Popma commented on LOG4J2-909:
------------------------------------

Improvements for Log4j JMX status logging:

{code}
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
index 68420a3..83e644c 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
@@ -33,7 +33,7 @@
 
     // LOG4J2-666 ensure unique name across separate instances created by 
webapp classloaders
     private static final AsyncLoggerContext CONTEXT = new 
AsyncLoggerContext("AsyncLoggerContext@"
-            + AsyncLoggerContext.class.hashCode());
+            + Integer.toHexString(AsyncLoggerContext.class.hashCode()));
 
     /**
      * Returns {@code true} if the user specified this selector as the 
Log4jContextSelector, to make all loggers
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
index 1ea55e9..4860551 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
@@ -161,8 +161,11 @@
                 LOGGER.debug("Could not register MBeans: no ContextSelector 
found.");
                 return;
             }
+            LOGGER.trace("Reregistering MBeans after reconfigure. 
Selector={}", selector);
             final List<LoggerContext> contexts = selector.getLoggerContexts();
+            int i = 0;
             for (final LoggerContext ctx : contexts) {
+                LOGGER.trace("Reregistering context ({}/{}): '{}' {}", ++i, 
contexts.size(), ctx.getName(), ctx);
                 // first unregister the context and all nested loggers,
                 // appenders, statusLogger, contextSelector, ringbuffers...
                 unregisterLoggerContext(ctx.getName(), mbs);
@@ -329,8 +332,12 @@
         try {
             final ObjectName pattern = new ObjectName(search);
             final Set<ObjectName> found = mbs.queryNames(pattern, null);
+            if (found.isEmpty()) {
+               LOGGER.trace("Unregistering but no MBeans found matching '{}'", 
search);
+            } else {
+               LOGGER.trace("Unregistering {} MBeans: {}", found.size(), 
found);
+            }
             for (final ObjectName objectName : found) {
-                LOGGER.debug("Unregistering MBean {}", objectName);
                 mbs.unregisterMBean(objectName);
             }
         } catch (final Exception ex) {
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
index e3b5679..f7fa5d4 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
@@ -169,7 +169,7 @@
     }
 
     private String toContextMapKey(final ClassLoader loader) {
-        return String.valueOf(System.identityHashCode(loader));
+        return Integer.toHexString(System.identityHashCode(loader));
     }
 
     protected LoggerContext getDefault() {
{code}

> StatusLogger Could not reconfigure JMX java.lang.NoClassDefFoundError: 
> sun/management/ExtendedPlatformComponent
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-909
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-909
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators, JMX
>    Affects Versions: 2.1
>         Environment: - OS: Ubuntu 14.10
> - JDK: Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b15)
>            Reporter: Behrooz Nobakht
>
> I have started to see the following stack track after an upgrade to the 
> mentioned JDK in the environment:
> {noformat}
> ERROR StatusLogger No log4j2 configuration file found. Using default 
> configuration: logging only errors to the console.
> ERROR StatusLogger Could not reconfigure JMX java.lang.NoClassDefFoundError: 
> sun/management/ExtendedPlatformComponent
>       at 
> java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:494)
>       at 
> org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:120)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:370)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
>       at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
> {noformat}
> I use a custom {{org.apache.logging.log4j.core.config.ConfigurationFactory}} 
> to configure my setup with {{@Order(0)}} and not using XML configuration.
> There is no explicit mention of moving/deleting such such in [the release 
> notes|http://download.java.net/jdk8u40/changes/jdk8u40-b15.html?q=download/jdk8u40/changes/jdk8u40-b15.html]
>  of the referenced JDK version.
> Is there anyway I can disable this JMX server internally configured by log4j2?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to