summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2009-08-16 20:35:30 +0000
committerRobert Gemmell <robbie@apache.org>2009-08-16 20:35:30 +0000
commitb964a52247b0405f2f6da647bff3ac74ad2ab6c6 (patch)
tree939e56db39618cf1778c642e5a6f5247e5d68532
parent65c3073fd7c2ab4ed116108f8b8a3440b409c134 (diff)
downloadqpid-python-b964a52247b0405f2f6da647bff3ac74ad2ab6c6.tar.gz
QPID-2016: Add ability to reload the Log4J configuration file on request using the management console
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@804767 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java37
-rw-r--r--qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java11
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java40
3 files changed, 87 insertions, 1 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
index e1e6cb49b5..1ab9d913c8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
@@ -753,4 +753,41 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM
LOCK.unlock();
}
}
+
+ public synchronized void reloadConfigFile() throws IOException
+ {
+ try
+ {
+ LOCK.lock();
+
+ QpidLog4JConfigurator.configure(_log4jConfigFileName);
+ _logger.info("Applied log4j configuration from: " + _log4jConfigFileName);
+ }
+ catch (IllegalLoggerLevelException e)
+ {
+ _logger.warn("The log4j configuration reload request was aborted: " + e);
+ //recommended that MBeans should use standard java.* and javax.* exceptions only
+ throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+ }
+ catch (ParserConfigurationException e)
+ {
+ _logger.warn("The log4j configuration reload request was aborted: " + e);
+ throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+ }
+ catch (SAXException e)
+ {
+ _logger.warn("The log4j configuration reload request was aborted: " + e);
+ //recommended that MBeans should use standard java.* and javax.* exceptions only
+ throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+ }
+ catch (IOException e)
+ {
+ _logger.warn("The log4j configuration reload request was aborted: " + e);
+ throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+ }
+ finally
+ {
+ LOCK.unlock();
+ }
+ }
}
diff --git a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java
index d9c5f59bd0..98dba9fed1 100644
--- a/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java
+++ b/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java
@@ -36,7 +36,7 @@ import javax.management.openmbean.TabularData;
public interface LoggingManagement
{
String TYPE = "LoggingManagement";
- int VERSION = 1;
+ int VERSION = 2;
//TabularType and contained CompositeType key/description information
//For compatibility reasons, DONT MODIFY the existing key values if expanding the set.
@@ -107,6 +107,15 @@ public interface LoggingManagement
//****** log4j XML configuration file operations ****** //
/**
+ * Reloads the log4j configuration file, applying any changes made.
+ *
+ * @throws IOException
+ * @since Qpid JMX API 1.3
+ */
+ @MBeanOperation(name = "reloadConfigFile", description = "Reload the log4j xml configuration file", impact = MBeanOperationInfo.ACTION)
+ void reloadConfigFile() throws IOException;
+
+ /**
* Updates the level of an existing Log4J logger within the xml configuration file
* @param logger The name of the logger
* @param level The level to set the logger to
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java
index 6af90d117c..e2c3c2a075 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java
@@ -30,6 +30,7 @@ import javax.management.openmbean.TabularDataSupport;
import static org.apache.qpid.management.ui.Constants.FONT_BOLD;
+import org.apache.qpid.management.ui.ApiVersion;
import org.apache.qpid.management.ui.ApplicationRegistry;
import org.apache.qpid.management.ui.ManagedBean;
import org.apache.qpid.management.common.mbeans.LoggingManagement;
@@ -80,6 +81,7 @@ public class ConfigurationFileTabControl extends TabControl
private String[] _availableLoggerLevels;
private TabularDataSupport _configFileLoggerLevels = null;
private LoggingManagement _lmmb;
+ private ApiVersion _ApiVersion;
static final String LOGGER_NAME = LoggingManagement.COMPOSITE_ITEM_NAMES[0];
static final String LOGGER_LEVEL = LoggingManagement.COMPOSITE_ITEM_NAMES[1];
@@ -91,6 +93,7 @@ public class ConfigurationFileTabControl extends TabControl
_lmmb = (LoggingManagement)
MBeanServerInvocationHandler.newProxyInstance(mbsc, mbean.getObjectName(),
LoggingManagement.class, false);
+ _ApiVersion = ApplicationRegistry.getServerRegistry(mbean).getManagementApiVersion();
_toolkit = new FormToolkit(_tabFolder.getDisplay());
_form = _toolkit.createScrolledForm(_tabFolder);
_form.getBody().setLayout(new GridLayout());
@@ -341,6 +344,43 @@ public class ConfigurationFileTabControl extends TabControl
_logWatchIntervalLabel = _toolkit.createLabel(logWatchIntervalGroup, "-");
_logWatchIntervalLabel.setFont(ApplicationRegistry.getFont(FONT_BOLD));
_logWatchIntervalLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
+
+ if(_ApiVersion.greaterThanOrEqualTo(1, 3))
+ {
+ Group reloadConfigFileGroup = new Group(attributesComposite, SWT.SHADOW_NONE);
+ reloadConfigFileGroup.setBackground(attributesComposite.getBackground());
+ reloadConfigFileGroup.setText("Reload Configuration File");
+ gridData = new GridData(SWT.LEFT, SWT.TOP, true, false);
+ reloadConfigFileGroup.setLayoutData(gridData);
+ reloadConfigFileGroup.setLayout(new GridLayout());
+
+ final Button reloadConfigFileButton = _toolkit.createButton(reloadConfigFileGroup, "Reload Config File", SWT.PUSH);
+ reloadConfigFileButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
+ reloadConfigFileButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ int response = ViewUtility.popupOkCancelConfirmationMessage("Reload",
+ "Reload Logging Configuration File?");
+ if (response == SWT.OK)
+ {
+ try
+ {
+ _lmmb.reloadConfigFile();
+ ViewUtility.operationResultFeedback(null, "Reloaded Logging Configuration File", null);
+
+ }
+ catch (Exception ex)
+ {
+ ViewUtility.operationFailedStatusBarMessage("Error Reloading Logging Configuration File");
+ MBeanUtility.handleException(_mbean, ex);
+ }
+
+ refresh(_mbean);;
+ }
+ }
+ });
+ }
}