[ https://issues.apache.org/jira/browse/ZOOKEEPER-3070?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jahar resolved ZOOKEEPER-3070. ------------------------------ Resolution: Not A Problem Fix Version/s: 3.4.5 Just found the way to achieve it. Was straight forward but I went into different direction. Below is the code: {quote}_JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2167/jmxrmi");_ _JMXConnector jmxConnector = JMXConnectorFactory.connect(url);_ _MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();_ _ObjectName mbeanName2 = new ObjectName("log4j:logger=root");_ _System.out.println(mbeanServerConnection.getAttribute(mbeanName2, "priority"));_ _mbeanServerConnection.setAttribute(mbeanName2, new Attribute("priority", "DEBUG"));_ {quote} > Not Able to Change Zookeeper Logging via JMX Call > ------------------------------------------------- > > Key: ZOOKEEPER-3070 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3070 > Project: ZooKeeper > Issue Type: Improvement > Components: jmx > Affects Versions: 3.4.5 > Environment: Using Java 8 for writing standalone code to update the > MBeans in zookeeper which is running in Windows machine for POC purpose. > Zookeeper Version is : 3.4.5 > Reporter: jahar > Priority: Blocker > Fix For: 3.4.5 > > Attachments: jconsole.JPG, zkpg.JPG > > > Hi, > I wanted to change the logging level of zookeeper dynamically via a JMX call > programmatically. Apache Zookeeper official page specifies that it is > possible to change the Mbeans via JMX calls and I have verified this through > JConsole also. > !zkpg.JPG! > But the problem is that I am not able to update the Mbeans related to log4j > through my code. I do see an API which can be used to access the Mbeans > related to Object "org.apache.ZooKeeperService:name0=StandaloneServer_port-1" > below is the screengrab of Jconsole and my code: > !jconsole.JPG! > > Here goes my Code: > {quote}public static void main(String[] args) throws Exception > { > JMXServiceURL url = new > JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2167/jmxrmi"); > JMXConnector jmxConnector = JMXConnectorFactory.connect(url); > MBeanServerConnection mbeanServerConnection = > jmxConnector.getMBeanServerConnection(); > ObjectName mbeanName = new > ObjectName("org.apache.ZooKeeperService:name0=StandaloneServer_port-1"); > ZooKeeperServerMXBean newProxyInstance = > MBeanServerInvocationHandler.newProxyInstance(mbeanServerConnection, > mbeanName, ZooKeeperServerMXBean.class, true); > System.out.println(newProxyInstance.getClientPort()); > } > {quote} > > > I dont see any API which can be used to access and update the log4J Mbeans > e.g. "root". What I want to achieve is to update the logging of zookeeper > without taking a restart. > Please advice if some API is exposed to achieve this. -- This message was sent by Atlassian JIRA (v7.6.3#76005)