You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/09/11 02:28:02 UTC

logging-log4j2 git commit: LOG4J2-1119 Disable JMX support by default.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 3f36ddf32 -> 608406122


LOG4J2-1119 Disable JMX support by default.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/60840612
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/60840612
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/60840612

Branch: refs/heads/master
Commit: 608406122883eb5f4b84c7b2b7a51c04aef07842
Parents: 3f36ddf
Author: rpopma <rp...@apache.org>
Authored: Fri Sep 11 09:27:57 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Fri Sep 11 09:27:57 2015 +0900

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/jmx/Server.java  | 10 +++++++---
 src/changes/changes.xml                            |  3 +++
 src/site/xdoc/manual/configuration.xml.vm          |  4 +++-
 src/site/xdoc/manual/jmx.xml.vm                    | 17 +++++++++++------
 4 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/60840612/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
----------------------------------------------------------------------
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 f2581e3..917426d 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
@@ -62,7 +62,7 @@ public final class Server {
     private static final String PROPERTY_ASYNC_NOTIF = "log4j2.jmx.notify.async";
     private static final String THREAD_NAME_PREFIX = "log4j2.jmx.notif";
     private static final StatusLogger LOGGER = StatusLogger.getLogger();
-    static final Executor executor = createExecutor();
+    static final Executor executor = isJmxDisabled() ? null : createExecutor();
 
     private Server() {
     }
@@ -132,10 +132,14 @@ public final class Server {
         }
         return sb.toString();
     }
+    
+    private static boolean isJmxDisabled() {
+        return PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_DISABLE_JMX, true);
+    }
 
     public static void reregisterMBeansAfterReconfigure() {
         // avoid creating Platform MBean Server if JMX disabled
-        if (PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_DISABLE_JMX)) {
+        if (isJmxDisabled()) {
             LOGGER.debug("JMX disabled for log4j2. Not registering MBeans.");
             return;
         }
@@ -144,7 +148,7 @@ public final class Server {
     }
 
     public static void reregisterMBeansAfterReconfigure(final MBeanServer mbs) {
-        if (PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_DISABLE_JMX)) {
+        if (isJmxDisabled()) {
             LOGGER.debug("JMX disabled for log4j2. Not registering MBeans.");
             return;
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/60840612/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f693302..0b2d597 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -40,6 +40,9 @@
       <action issue="LOG4J2-1118" dev="rpopma" type="add">
         Updated Logger wrapper generator tool to add Java 8 lambda support for custom log levels.
       </action>
+      <action issue="LOG4J2-1119" dev="rpopma" type="update">
+        Disable JMX support by default. Users now need to explicitly switch JMX support on.
+      </action>
       <action issue="LOG4J2-1107" dev="ggregory" type="add" due-to="Mikael Ståldal">
         New Appender for Apache Kafka.
       </action>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/60840612/src/site/xdoc/manual/configuration.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
index 054dcd3..ad825e3 100644
--- a/src/site/xdoc/manual/configuration.xml.vm
+++ b/src/site/xdoc/manual/configuration.xml.vm
@@ -1496,10 +1496,12 @@ public class AwesomeTest {
   </tr>
   <tr>
     <td>log4j2.disable.jmx</td>
-    <td>false</td>
+    <td>true</td>
     <td>
       If <tt>true</tt>, Log4j configuration objects like LoggerContexts, Appenders, Loggers, etc.
       will not be instrumented with MBeans and cannot be remotely monitored and managed.
+      <p>From 2.4 the <a href="jmx.html#Enabling_JMX">default was changed</a> and users now need
+      to explicitly enable JMX support.</p>
     </td>
   </tr>
   <tr>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/60840612/src/site/xdoc/manual/jmx.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/jmx.xml.vm b/src/site/xdoc/manual/jmx.xml.vm
index 3a6498c..0d6df37 100644
--- a/src/site/xdoc/manual/jmx.xml.vm
+++ b/src/site/xdoc/manual/jmx.xml.vm
@@ -40,12 +40,17 @@
       </section>
       <section name="Enabling JMX">
         <a name="Enabling_JMX" />
-        <p>JMX support is enabled by default. When Log4j initializes,
-        the StatusLogger, ContextSelector, and all LoggerContexts,
-          LoggerConfigs and Appenders are instrumented with MBeans.
-        To disable JMX completely, and prevent these MBeans from being created,
-        specify system property <code>log4j2.disable.jmx=true</code> when you start
-        the Java VM.
+        <p>JMX support is <em>disabled</em> by default. 
+        	You can enable JMX support by specifying system property
+        	<code>log4j2.disable.jmx=false</code> when you start the Java VM,
+        and the StatusLogger, ContextSelector, and all LoggerContexts,
+          LoggerConfigs and Appenders will be instrumented with MBeans.
+        </p><p>
+          Note: In Log4j 2 versions up to and including 2.3, JMX support was
+          enabled by default. From 2.4 users need to explicitly enable JMX support.
+          We made this change because the default JMX transport is RMI, and RMI by default triggers a full GC every hour.
+          See the <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/sunrmiproperties.html">Oracle
+          documentation</a> for the <code>sun.rmi.dgc.server.gcInterval</code> property.
         </p>
 		<subsection name="Local Monitoring and Management">
       <a name="Local" />