You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Abhinav Shah (JIRA)" <ji...@apache.org> on 2013/09/06 18:25:57 UTC
[jira] [Closed] (LOG4J2-396) Disable JMX by default
[ https://issues.apache.org/jira/browse/LOG4J2-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Abhinav Shah closed LOG4J2-396.
-------------------------------
> Disable JMX by default
> ----------------------
>
> Key: LOG4J2-396
> URL: https://issues.apache.org/jira/browse/LOG4J2-396
> Project: Log4j 2
> Issue Type: Improvement
> Components: JMX
> Affects Versions: 2.0-beta8
> Reporter: Abhinav Shah
>
> Shouldn't we disable JMX by default?
> I see currently in Log4jContextFactory, the MBeans are being registered by default -
> {code}
> public Log4jContextFactory() {
> final String sel = PropertiesUtil.getProperties().getStringProperty(Constants.LOG4J_CONTEXT_SELECTOR);
> if (sel != null) {
> try {
> final Class<?> clazz = Loader.loadClass(sel);
> if (clazz != null && ContextSelector.class.isAssignableFrom(clazz)) {
> selector = (ContextSelector) clazz.newInstance();
> }
> } catch (final Exception ex) {
> LOGGER.error("Unable to create context " + sel, ex);
> }
> }
> if (selector == null) {
> selector = new ClassLoaderContextSelector();
> }
> try {
> Server.registerMBeans(selector);
> } catch (final Exception ex) {
> LOGGER.error("Could not start JMX", ex);
> }
> }
> {code}
> The is causing errors in my standalone java application which is a simple console utility.
> I am getting the following error as Log4j tries to register MBeans -
> {code}
> java.lang.IllegalAccessError: tried to access method javax.management.StandardMBean.<init>(Ljava/lang/Object;Ljava/lang/Class;Z)V from class sun.management.ManagementFactory
> at sun.management.ManagementFactory.addMXBean(ManagementFactory.java:249)
> at sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:304)
> at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:504)
> at org.apache.logging.log4j.core.jmx.Server.registerMBeans(Server.java:107)
> at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:59)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at java.lang.Class.newInstance0(Class.java:355)
> at java.lang.Class.newInstance(Class.java:308)
> at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:85)
> at org.slf4j.helpers.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:90)
> at org.slf4j.helpers.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:46)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
> at com.labcorp.eag.util.jms.SaveQueueToFiles.<clinit>(SaveQueueToFiles.java:45)
> Exception in thread "main"
> {code}
> Currently I overcome this error by setting
> {code}
> -Dlog4j2.disable.jmx=true
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org