Search in sources :

Example 1 with StatusLoggerAdminMBean

use of org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean in project logging-log4j2 by apache.

the class ClientGui method addWidgetForLoggerContext.

private void addWidgetForLoggerContext(final LoggerContextAdminMBean ctx) throws MalformedObjectNameException, IOException, InstanceNotFoundException {
    final JTabbedPane contextTabs = new JTabbedPane();
    contextObjNameToTabbedPaneMap.put(ctx.getObjectName(), contextTabs);
    tabbedPaneContexts.addTab("LoggerContext: " + ctx.getName(), contextTabs);
    final String contextName = ctx.getName();
    final StatusLoggerAdminMBean status = client.getStatusLoggerAdmin(contextName);
    if (status != null) {
        final JTextArea text = createTextArea();
        final String[] messages = status.getStatusDataHistory();
        for (final String message : messages) {
            text.append(message + '\n');
        }
        statusLogTextAreaMap.put(ctx.getObjectName(), text);
        registerListeners(status);
        final JScrollPane scroll = scroll(text);
        contextTabs.addTab("StatusLogger", scroll);
    }
    final ClientEditConfigPanel editor = new ClientEditConfigPanel(ctx);
    contextTabs.addTab("Configuration", editor);
}
Also used : StatusLoggerAdminMBean(org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean) JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) JTabbedPane(javax.swing.JTabbedPane)

Example 2 with StatusLoggerAdminMBean

use of org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean in project logging-log4j2 by apache.

the class Client method getStatusLoggerAdmin.

/**
     * Returns the {@code StatusLoggerAdminMBean} associated with the specified
     * context name, or {@code null}.
     *
     * @param contextName search key
     * @return StatusLoggerAdminMBean or null
     * @throws MalformedObjectNameException If an object name is malformed
     * @throws IOException If an I/O error occurred
     */
public StatusLoggerAdminMBean getStatusLoggerAdmin(final String contextName) throws MalformedObjectNameException, IOException {
    final String pattern = StatusLoggerAdminMBean.PATTERN;
    final String mbean = String.format(pattern, Server.escape(contextName));
    final ObjectName search = new ObjectName(mbean);
    final Set<ObjectName> result = connection.queryNames(search, null);
    if (result.size() == 0) {
        return null;
    }
    if (result.size() > 1) {
        System.err.println("WARN: multiple status loggers found for " + contextName + ": " + result);
    }
    final StatusLoggerAdminMBean proxy = //
    JMX.newMBeanProxy(//
    connection, //
    result.iterator().next(), StatusLoggerAdminMBean.class, // notificationBroadcaster
    true);
    return proxy;
}
Also used : StatusLoggerAdminMBean(org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean) ObjectName(javax.management.ObjectName)

Aggregations

StatusLoggerAdminMBean (org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean)2 ObjectName (javax.management.ObjectName)1 JScrollPane (javax.swing.JScrollPane)1 JTabbedPane (javax.swing.JTabbedPane)1 JTextArea (javax.swing.JTextArea)1