JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 

Remote logging via JMX

From JPPF 6.3 Documentation

Revision as of 08:49, 25 November 2019 by Lolocohen (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Main Page > Management and monitoring > JMX logging


It is possible to receive logging messages from a JPPF driver or node as JMX notifications. Specific implementations are available for Log4j and JDK logging.

To configure Log4j to send JMX notifications, edit the log4j configuration files of the driver or node and add the following:

### direct messages to the JMX Logger ###
log4j.appender.JMX=org.jppf.logging.log4j.JmxAppender
log4j.appender.JMX.layout=org.apache.log4j.PatternLayout
log4j.appender.JMX.layout.ConversionPattern=%d [%-5p][%c.%M(%L)]: %m\n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=INFO, JPPF, JMX

To configure the JDK logging to send JMX notifications, edit the JDK logging configuration file of the driver or node, as follows:

# list of handlers
handlers= java.util.logging.FileHandler, org.jppf.logging.jdk.JmxHandler
org.jppf.logging.jdk.JmxHandler.level = FINEST
org.jppf.logging.jdk.JmxHandler.formatter = java.util.logging.SimpleFormatter

To receive the logging notifications from a remote application, you can use the following code:

// get a JMX connection to the node MBean server
JMXDriverConnectionWrapper driver = new JMXDriverConnectionWrapper(host, port, secure);
driver.connectAndWait(5000L);
// get a proxy to the MBean
JmxLogger logger = driver.getProxy(JmxLogger.DEFAULT_MBEAN_NAME, JmxLogger.class);
// use a handback object so we know where the log messages come from
String source = "driver " + driver.getHost() + ":" + jmxDriver.getPort();
// subbscribe to all notifications from the MBean
NotificationListener listener = new MyLoggingHandler();
logger.addNotificationListener(listener, null, source);

// Logging notification listener that prints remote log messages to the console
public class MyLoggingHandler implements NotificationListener {
  // handle the logging notifications
  @Override
  public void handleNotification(Notification notification, Object source) {
    System.out.println(source.toString() + ": " + notification.getMessage());
  }
}
Main Page > Management and monitoring > JMX logging



JPPF Copyright © 2005-2020 JPPF.org Powered by MediaWiki