summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2010-08-26 15:03:33 +0000
committerRobert Gemmell <robbie@apache.org>2010-08-26 15:03:33 +0000
commitaa17f5797a4ec71e7baa271a22a4e9524238646e (patch)
tree8330d9b095b3fb317858174f867dce6c6e9f725a
parentc24a2f22ac211ccbf77b253f727db28bece92d83 (diff)
downloadqpid-python-aa17f5797a4ec71e7baa271a22a4e9524238646e.tar.gz
QPID-2802: Add support for a status-logging hierarchy, such that the Log4jMessageLogger may use this to allow individual on/off toggling of each status message. Combine the RootLogger and RawLogger interfaces.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@989734 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/etc/log4j.xml12
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/Main.java4
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java (renamed from java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java)34
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/LogMessage.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/NullRootMessageLogger.java31
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/RawMessageLogger.java44
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLogger.java23
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/SystemOutMessageLogger.java (renamed from java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java)28
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java10
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLogger.java53
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java40
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java4
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java2
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java (renamed from java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLoggerTest.java)17
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/RootMessageLoggerImplTest.java86
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java (renamed from java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLogger.java)34
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLoggerTest.java (renamed from java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLoggerTest.java)13
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java63
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java5
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java42
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java2
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java48
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java17
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java17
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java24
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java20
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java16
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java4
-rw-r--r--java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm18
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java2
-rw-r--r--java/test-profiles/log4j-test.xml4
31 files changed, 254 insertions, 465 deletions
diff --git a/java/broker/etc/log4j.xml b/java/broker/etc/log4j.xml
index cfdfacb290..458329571e 100644
--- a/java/broker/etc/log4j.xml
+++ b/java/broker/etc/log4j.xml
@@ -103,6 +103,12 @@
<priority value="warn"/>
</category>
+ <!-- Enable info messages for the status-logging hierarchy -->
+ <logger additivity="true" name="qpid.message">
+ <level value="info"/>
+ </logger>
+
+
<!-- Examples of additional logging settings -->
<!-- Used to generate extra debug. See debug.log4j.xml -->
@@ -112,9 +118,9 @@
</category-->
<!-- Set the commons logging that the XML parser uses to WARN, it is very chatty at debug -->
- <logger name="org.apache.commons">
- <level value="WARN"/>
- </logger>
+ <logger name="org.apache.commons">
+ <level value="WARN"/>
+ </logger>
<!-- Log all info events to file -->
<root>
diff --git a/java/broker/src/main/java/org/apache/qpid/server/Main.java b/java/broker/src/main/java/org/apache/qpid/server/Main.java
index 4bca4e5161..7d7eefc541 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/Main.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/Main.java
@@ -46,7 +46,7 @@ import org.apache.qpid.framing.ProtocolVersion;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
import org.apache.qpid.server.information.management.ServerInformationMBean;
-import org.apache.qpid.server.logging.StartupRootMessageLogger;
+import org.apache.qpid.server.logging.SystemOutMessageLogger;
import org.apache.qpid.server.logging.actors.BrokerActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.management.LoggingManagementMBean;
@@ -223,7 +223,7 @@ public class Main
{
try
{
- CurrentActor.set(new BrokerActor(new StartupRootMessageLogger()));
+ CurrentActor.set(new BrokerActor(new SystemOutMessageLogger()));
startup();
CurrentActor.remove();
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java b/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java
index a3bf276d1e..545f2adea2 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java
@@ -22,36 +22,38 @@ package org.apache.qpid.server.logging;
import org.apache.qpid.server.configuration.ServerConfiguration;
-public class RootMessageLoggerImpl implements RootMessageLogger
+public abstract class AbstractRootMessageLogger implements RootMessageLogger
{
- private boolean _enabled;
+ public static final String DEFAULT_LOG_HIERARCHY_PREFIX = "qpid.message.";
+
+ private boolean _enabled = true;
- RawMessageLogger _rawLogger;
- private static final String MESSAGE = "MESSAGE ";
+ public AbstractRootMessageLogger()
+ {
- public RootMessageLoggerImpl(ServerConfiguration configuration, RawMessageLogger rawLogger)
+ }
+
+ public AbstractRootMessageLogger(ServerConfiguration config)
{
- _enabled = configuration.getStatusUpdatesEnabled();
- _rawLogger = rawLogger;
+ _enabled = config.getStatusUpdatesEnabled();
}
-
- public boolean isMessageEnabled(LogActor actor, LogSubject subject)
+
+ public boolean isEnabled()
{
return _enabled;
}
- public boolean isMessageEnabled(LogActor actor)
+ public boolean isMessageEnabled(LogActor actor, LogSubject subject, String logHierarchy)
{
return _enabled;
}
- public void rawMessage(String message)
+ public boolean isMessageEnabled(LogActor actor, String logHierarchy)
{
- _rawLogger.rawMessage(MESSAGE + message);
+ return _enabled;
}
- public void rawMessage(String message, Throwable throwable)
- {
- _rawLogger.rawMessage(MESSAGE + message, throwable);
- }
+ public abstract void rawMessage(String message, String logHierarchy);
+
+ public abstract void rawMessage(String message, Throwable throwable, String logHierarchy);
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/LogMessage.java b/java/broker/src/main/java/org/apache/qpid/server/logging/LogMessage.java
index 5c112ff100..fa18435fab 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/LogMessage.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/LogMessage.java
@@ -22,5 +22,5 @@ package org.apache.qpid.server.logging;
public interface LogMessage
{
-
+ String getLogHierarchy();
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/NullRootMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/NullRootMessageLogger.java
index 6cd29b95fb..db8b24e90e 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/NullRootMessageLogger.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/NullRootMessageLogger.java
@@ -20,41 +20,28 @@
*/
package org.apache.qpid.server.logging;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-
-public class NullRootMessageLogger extends RootMessageLoggerImpl
+public class NullRootMessageLogger extends AbstractRootMessageLogger
{
- public NullRootMessageLogger() throws ConfigurationException
- {
- super(new ServerConfiguration(new PropertiesConfiguration()), new NullMessageLogger());
- }
-
@Override
- public boolean isMessageEnabled(LogActor actor, LogSubject subject)
+ public boolean isMessageEnabled(LogActor actor, LogSubject subject, String logHeirarchy)
{
return false;
}
@Override
- public boolean isMessageEnabled(LogActor actor)
+ public boolean isMessageEnabled(LogActor actor, String logHierarchy)
{
return false;
}
- public static class NullMessageLogger implements RawMessageLogger
+ public void rawMessage(String message, String logHierarchy)
{
- public void rawMessage(String message)
- {
- // drop message
- }
-
- public void rawMessage(String message, Throwable throwable)
- {
- // drop message
- }
+ // drop message
}
+ public void rawMessage(String message, Throwable throwable, String logHierarchy)
+ {
+ // drop message
+ }
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/RawMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/RawMessageLogger.java
deleted file mode 100644
index 7d515f3263..0000000000
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/RawMessageLogger.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server.logging;
-
-/**
- * A RawMessage Logger takes the given String and any Throwable and writes the
- * data to its resource.
- */
-public interface RawMessageLogger
-{
-
- /**
- * Log the given message.
- *
- * @param message String to log.
- */
- public void rawMessage(String message);
-
- /**
- * Log the message and formatted stack trace for any Throwable.
- *
- * @param message String to log.
- * @param throwable Throwable for which to provide stack trace.
- */
- public void rawMessage(String message, Throwable throwable);
-} \ No newline at end of file
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLogger.java
index 5ac5eab6c4..1431dd1da9 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLogger.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLogger.java
@@ -28,30 +28,40 @@ package org.apache.qpid.server.logging;
public interface RootMessageLogger
{
/**
+ * Determine whether the MessageLogger is enabled
+ *
+ * @return boolean true if enabled.
+ */
+ boolean isEnabled();
+
+ /**
* Determine if the LogSubject and the LogActor should be
* generating log messages.
- *
- * @param subject The subject of this log request
* @param actor The actor requesting the logging
+ * @param subject The subject of this log request
+ * @param logHierarchy The log hierarchy for this request
+ *
* @return boolean true if the message should be logged.
*/
- boolean isMessageEnabled(LogActor actor, LogSubject subject);
+ boolean isMessageEnabled(LogActor actor, LogSubject subject, String logHierarchy);
/**
* Determine if the LogActor should be generating log messages.
*
* @param actor The actor requesting the logging
+ * @param logHierarchy The log hierarchy for this request
*
* @return boolean true if the message should be logged.
*/
- boolean isMessageEnabled(LogActor actor);
+ boolean isMessageEnabled(LogActor actor, String logHierarchy);
/**
* Log the raw message to the configured logger.
*
* @param message The message to log
+ * @param logHierarchy The log hierarchy for this request
*/
- public void rawMessage(String message);
+ public void rawMessage(String message, String logHierarchy);
/**
* Log the raw message to the configured logger.
@@ -59,6 +69,7 @@ public interface RootMessageLogger
*
* @param message The message to log
* @param throwable Optional Throwable that should provide stact trace
+ * @param logHierarchy The log hierarchy for this request
*/
- void rawMessage(String message, Throwable throwable);
+ void rawMessage(String message, Throwable throwable, String logHierarchy);
} \ No newline at end of file
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/SystemOutMessageLogger.java
index bfb122985b..b384b3fde3 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/SystemOutMessageLogger.java
@@ -20,30 +20,32 @@
*/
package org.apache.qpid.server.logging;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.rawloggers.SystemOutMessageLogger;
-public class StartupRootMessageLogger extends RootMessageLoggerImpl
+public class SystemOutMessageLogger extends AbstractRootMessageLogger
{
- public StartupRootMessageLogger() throws ConfigurationException
- {
- super(new ServerConfiguration(new PropertiesConfiguration()),
- new SystemOutMessageLogger());
- }
-
@Override
- public boolean isMessageEnabled(LogActor actor, LogSubject subject)
+ public boolean isMessageEnabled(LogActor actor, LogSubject subject, String logHeirarchy)
{
return true;
}
@Override
- public boolean isMessageEnabled(LogActor actor)
+ public boolean isMessageEnabled(LogActor actor, String logHierarchy)
{
return true;
}
+ public void rawMessage(String message, String logHierarchy)
+ {
+ rawMessage(message, null, logHierarchy);
+ }
+ public void rawMessage(String message, Throwable throwable, String logHierarchy)
+ {
+ System.out.println(message);
+ if (throwable != null)
+ {
+ throwable.printStackTrace(System.out);
+ }
+ }
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java b/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
index 1fa2bd9600..05ac8c4b7e 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
@@ -27,6 +27,8 @@ import org.apache.qpid.server.logging.RootMessageLogger;
public abstract class AbstractActor implements LogActor
{
+ public static final String DEFAULT_MSG_PREFIX = "MESSAGE ";
+
protected RootMessageLogger _rootLogger;
public AbstractActor(RootMessageLogger rootLogger)
@@ -40,17 +42,17 @@ public abstract class AbstractActor implements LogActor
public void message(LogSubject subject, LogMessage message)
{
- if (_rootLogger.isMessageEnabled(this, subject))
+ if (_rootLogger.isMessageEnabled(this, subject, message.getLogHierarchy()))
{
- _rootLogger.rawMessage(getLogMessage() + String.valueOf(subject) + message);
+ _rootLogger.rawMessage(DEFAULT_MSG_PREFIX + getLogMessage() + String.valueOf(subject) + message, message.getLogHierarchy());
}
}
public void message(LogMessage message)
{
- if (_rootLogger.isMessageEnabled(this))
+ if (_rootLogger.isMessageEnabled(this, message.getLogHierarchy()))
{
- _rootLogger.rawMessage(getLogMessage() + message);
+ _rootLogger.rawMessage(DEFAULT_MSG_PREFIX + getLogMessage() + message, message.getLogHierarchy());
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLogger.java
index f996576f31..fffd16a812 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLogger.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLogger.java
@@ -22,35 +22,56 @@ package org.apache.qpid.server.logging.rawloggers;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import org.apache.qpid.server.logging.RawMessageLogger;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.AbstractRootMessageLogger;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.LogSubject;
-public class Log4jMessageLogger implements RawMessageLogger
+public class Log4jMessageLogger extends AbstractRootMessageLogger
{
- public static final String DEFAULT_LEVEL = "INFO";
- public static final String DEFAULT_LOGGER = "qpid.message";
- private Level _level;
- private Logger _rawMessageLogger;
-
+ public static final Level LEVEL = Level.toLevel("INFO");
+
public Log4jMessageLogger()
{
- this(DEFAULT_LEVEL, DEFAULT_LOGGER);
+ super();
}
- public Log4jMessageLogger(String level, String logger)
+ public Log4jMessageLogger(ServerConfiguration config)
+ {
+ super(config);
+ }
+
+ @Override
+ public boolean isMessageEnabled(LogActor actor, LogSubject subject, String logHierarchy)
{
- _level = Level.toLevel(level);
+ return isMessageEnabled(actor, logHierarchy);
+ }
- _rawMessageLogger = Logger.getLogger(logger);
- _rawMessageLogger.setLevel(_level);
+ @Override
+ public boolean isMessageEnabled(LogActor actor, String logHierarchy)
+ {
+ if(isEnabled())
+ {
+ Logger logger = Logger.getLogger(logHierarchy);
+ return logger.isEnabledFor(LEVEL);
+ }
+ else
+ {
+ return false;
+ }
}
- public void rawMessage(String message)
+ @Override
+ public void rawMessage(String message, String logHierarchy)
{
- rawMessage(message, null);
+ rawMessage(message, null, logHierarchy);
}
- public void rawMessage(String message, Throwable throwable)
+ @Override
+ public void rawMessage(String message, Throwable throwable, String logHierarchy)
{
- _rawMessageLogger.log(_level, message, throwable);
+ Logger logger = Logger.getLogger(logHierarchy);
+
+ logger.log(LEVEL, message, throwable);
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java b/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java
deleted file mode 100644
index b9f0532d05..0000000000
--- a/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.logging.rawloggers;
-
-import org.apache.qpid.server.logging.RawMessageLogger;
-
-public class SystemOutMessageLogger implements RawMessageLogger
-{
- public void rawMessage(String message)
- {
- rawMessage(message, null);
- }
-
- public void rawMessage(String message, Throwable throwable)
- {
- System.out.println(message);
- if (throwable != null)
- {
- throwable.printStackTrace(System.out);
- }
- }
-}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
index bc68fa0c79..5cddfda059 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
@@ -39,7 +39,7 @@ import org.apache.qpid.server.configuration.SystemConfig;
import org.apache.qpid.server.configuration.SystemConfigImpl;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.AbstractRootMessageLogger;
import org.apache.qpid.server.logging.actors.BrokerActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.messages.BrokerMessages;
@@ -249,7 +249,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
public void initialise(int instanceID) throws Exception
{
- _rootMessageLogger = new RootMessageLoggerImpl(_configuration, new Log4jMessageLogger());
+ _rootMessageLogger = new Log4jMessageLogger(_configuration);
_registryName = String.valueOf(instanceID);
// Set the Actor for current log messages
diff --git a/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java b/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
index 1740e3db1a..d8f44c9f7f 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
@@ -362,7 +362,7 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
_logActor = new SubscriptionActor(CurrentActor.get().getRootMessageLogger(), this);
if (CurrentActor.get().getRootMessageLogger().
- isMessageEnabled(CurrentActor.get(), _logSubject))
+ isMessageEnabled(CurrentActor.get(), _logSubject, SubscriptionMessages.CREATE_LOG_HIERARCHY))
{
// Get the string value of the filters
String filterLogString = null;
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLoggerTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java
index 4b69a46793..5ccff7ec08 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/Log4jMessageLoggerTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/Log4jMessageLoggerTest.java
@@ -18,13 +18,14 @@
*
*
*/
-package org.apache.qpid.server.logging.rawloggers;
+package org.apache.qpid.server.logging;
import junit.framework.TestCase;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
+import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
import java.io.File;
import java.io.IOException;
@@ -87,7 +88,7 @@ public class Log4jMessageLoggerTest extends TestCase
String message = "testDefaults";
// Log the message
- logger.rawMessage(message);
+ logger.rawMessage(message, null, null);
verifyLogPresent(message);
}
@@ -106,6 +107,7 @@ public class Log4jMessageLoggerTest extends TestCase
testDefaultLogsMessage();
}
+ //TODO: use 2 different loggers rather than the default which isnt used anymore
/**
* Test that changing the logger works.
* <p/>
@@ -117,22 +119,22 @@ public class Log4jMessageLoggerTest extends TestCase
{
String loggerName = "TestLogger";
// Create a logger to test
- Log4jMessageLogger logger = new Log4jMessageLogger(Log4jMessageLogger.DEFAULT_LEVEL, loggerName);
+ Log4jMessageLogger logger = new Log4jMessageLogger();
//Create Message for test
String message = "testDefaults";
//Disable the default Log4jMessageLogger logger
- Level originalLevel = Logger.getLogger(Log4jMessageLogger.DEFAULT_LOGGER).getLevel();
- Logger.getLogger(Log4jMessageLogger.DEFAULT_LOGGER).setLevel(Level.OFF);
+ Level originalLevel = Logger.getLogger(Log4jMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX).getLevel();
+ Logger.getLogger(Log4jMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX).setLevel(Level.OFF);
// Log the message
- logger.rawMessage(message);
+ logger.rawMessage(message, null, loggerName);
verifyLogPresent(message);
// Restore the logging level
- Logger.getLogger(Log4jMessageLogger.DEFAULT_LOGGER).setLevel(originalLevel);
+ Logger.getLogger(Log4jMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX).setLevel(originalLevel);
}
@@ -163,7 +165,6 @@ public class Log4jMessageLoggerTest extends TestCase
{
List<String> results = findMessageInLog(message);
- //Validate we only got one message
if (results.size() > 0)
{
System.err.println("Unexpected Log messages");
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/RootMessageLoggerImplTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/RootMessageLoggerImplTest.java
deleted file mode 100644
index 012a590687..0000000000
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/RootMessageLoggerImplTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server.logging;
-
-import junit.framework.TestCase;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
-
-import java.util.List;
-
-public class RootMessageLoggerImplTest extends TestCase
-{
-
- RootMessageLogger _rootLogger;
- UnitTestMessageLogger _rawLogger;
-
- public void setUp() throws ConfigurationException
- {
- Configuration config = new PropertiesConfiguration();
- ServerConfiguration serverConfig = new ServerConfiguration(config);
-
- _rawLogger = new UnitTestMessageLogger();
-
- _rootLogger = new RootMessageLoggerImpl(serverConfig, _rawLogger);
- }
-
- public void tearDown()
- {
- _rawLogger.clearLogMessages();
- }
-
- public void testLog()
- {
- String message = "test logging";
-
- _rootLogger.rawMessage(message);
-
- List<Object> logs = _rawLogger.getLogMessages();
-
- assertEquals("Message log size not as expected.", 1, logs.size());
-
- assertTrue(logs.get(0).toString().contains(message));
- }
-
- public void testLogWithThrowable()
- {
- String message = "test logging";
- Exception exception = new Exception("Test");
-
- _rootLogger.rawMessage(message, exception);
-
- List<Object> logs = _rawLogger.getLogMessages();
-
- assertEquals("Message log size not as expected.", 2, logs.size());
-
- String loggedMessage = (String) logs.get(0);
- assertTrue("Message not found in log:" + loggedMessage,
- loggedMessage.contains(message));
-
- Exception fromLog = (Exception) logs.get(1);
- assertEquals(exception.getMessage(), fromLog.getMessage());
- }
-
-
-}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLogger.java b/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java
index df50cfb57a..3752dcb37e 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLogger.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLogger.java
@@ -18,32 +18,45 @@
*
*
*/
-package org.apache.qpid.server.logging.rawloggers;
+package org.apache.qpid.server.logging;
-import org.apache.qpid.server.logging.RawMessageLogger;
-
-import java.util.List;
import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.AbstractRootMessageLogger;
-public class UnitTestMessageLogger implements RawMessageLogger
+public class UnitTestMessageLogger extends AbstractRootMessageLogger
{
List<Object> _log;
-
- public UnitTestMessageLogger()
+
{
_log = new LinkedList<Object>();
}
+
+ public UnitTestMessageLogger()
+ {
+
+ }
+ public UnitTestMessageLogger(ServerConfiguration config)
+ {
+ super(config);
+ }
- public void rawMessage(String message)
+ public void rawMessage(String message, String logHierarchy)
{
_log.add(message);
}
- public void rawMessage(String message, Throwable throwable)
+ public void rawMessage(String message, Throwable throwable, String logHierarchy)
{
_log.add(message);
- _log.add(throwable);
+
+ if(throwable != null)
+ {
+ _log.add(throwable);
+ }
}
@@ -56,5 +69,4 @@ public class UnitTestMessageLogger implements RawMessageLogger
{
_log.clear();
}
-
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLoggerTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLoggerTest.java
index e10de48432..e2e112be8f 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/rawloggers/UnitTestMessageLoggerTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/UnitTestMessageLoggerTest.java
@@ -18,7 +18,7 @@
* under the License.
*
*/
-package org.apache.qpid.server.logging.rawloggers;
+package org.apache.qpid.server.logging;
import junit.framework.TestCase;
@@ -27,16 +27,17 @@ import java.util.List;
/**
* Test: UnitTestMessageLoggerTest
*
- * This test verifies that UnitTestMessageLogger adhears to its interface.
+ * This test verifies that UnitTestMessageLogger adheres to its interface.
*
* Messages are logged, and Throwables recorded in an array that can be
- * retreived and cleared.
+ * retrieved and cleared.
*
*/
public class UnitTestMessageLoggerTest extends TestCase
{
private static final String TEST_MESSAGE = "Test";
private static final String TEST_THROWABLE = "Test Throwable";
+ private static final String TEST_HIERARCHY = "test.hierarchy";
public void testRawMessage()
{
@@ -46,7 +47,7 @@ public class UnitTestMessageLoggerTest extends TestCase
logger.getLogMessages().size());
// Log a message
- logger.rawMessage(TEST_MESSAGE);
+ logger.rawMessage(TEST_MESSAGE, TEST_HIERARCHY);
List<Object> messages = logger.getLogMessages();
@@ -66,7 +67,7 @@ public class UnitTestMessageLoggerTest extends TestCase
// Log a message
Throwable throwable = new Throwable(TEST_THROWABLE);
- logger.rawMessage(TEST_MESSAGE, throwable);
+ logger.rawMessage(TEST_MESSAGE, throwable, TEST_HIERARCHY);
List<Object> messages = logger.getLogMessages();
@@ -88,7 +89,7 @@ public class UnitTestMessageLoggerTest extends TestCase
logger.getLogMessages().size());
// Log a message
- logger.rawMessage(TEST_MESSAGE);
+ logger.rawMessage(TEST_MESSAGE, null, TEST_HIERARCHY);
assertEquals("Expected to have 1 messages logged",
1, logger.getLogMessages().size());
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
index 2b684ac51b..c7727bfa1a 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
@@ -20,17 +20,12 @@
*/
package org.apache.qpid.server.logging.actors;
-import org.apache.commons.configuration.Configuration;
+import java.util.List;
+
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.qpid.AMQException;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
-import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.LogMessage;
-import org.apache.qpid.server.AMQChannel;
-
-import java.util.List;
+import org.apache.qpid.server.logging.LogSubject;
/**
* Test : AMQPChannelActorTest
@@ -78,7 +73,7 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
startBrokerNow();
- final String message = sendTestMessage();
+ final String message = sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -105,31 +100,6 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
}
/**
- * Log a message using the test Actor
- * @return the logged message
- */
- private String sendTestMessage()
- {
- final String message = "test logging";
-
- _amqpActor.message(new LogSubject()
- {
- public String toString()
- {
- return "[AMQPActorTest]";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return message;
- }
- });
- return message;
- }
-
- /**
* Test that if logging is configured to be off in the configuration that
* no logging is presented
* @throws ConfigurationException
@@ -139,13 +109,10 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "OFF");
- _rawLogger = new UnitTestMessageLogger();
-
// Start the broker now.
startBrokerNow();
-
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -163,11 +130,9 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "OfF");
- _rawLogger = new UnitTestMessageLogger();
-
startBrokerNow();
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -185,11 +150,9 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "Off");
- _rawLogger = new UnitTestMessageLogger();
-
startBrokerNow();
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -207,11 +170,9 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "ofF");
- _rawLogger = new UnitTestMessageLogger();
-
startBrokerNow();
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -229,11 +190,9 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "off");
- _rawLogger = new UnitTestMessageLogger();
-
startBrokerNow();
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
@@ -251,11 +210,9 @@ public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
_configXml.setProperty("status-updates", "oFf");
- _rawLogger = new UnitTestMessageLogger();
-
startBrokerNow();
- sendTestMessage();
+ sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
index 3e82eea51a..2cb950ee30 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
@@ -124,6 +124,11 @@ public class AMQPConnectionActorTest extends BaseConnectionActorTestCase
{
return message;
}
+
+ public String getLogHierarchy()
+ {
+ return "test.hieracrchy";
+ }
});
return message;
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
index 5f5cc4fca3..6a72a7aaf9 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
@@ -21,10 +21,11 @@
package org.apache.qpid.server.logging.actors;
import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
+import org.apache.qpid.server.logging.LogMessage;
+import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.UnitTestMessageLogger;
import org.apache.qpid.server.util.InternalBrokerBaseCase;
@@ -45,10 +46,8 @@ public class BaseActorTestCase extends InternalBrokerBaseCase
{
super.createBroker();
- _rawLogger = new UnitTestMessageLogger();
-
- _rootLogger =
- new RootMessageLoggerImpl(_configuration, _rawLogger);
+ _rawLogger = new UnitTestMessageLogger(_configuration);
+ _rootLogger = _rawLogger;
}
public void tearDown() throws Exception
@@ -58,4 +57,35 @@ public class BaseActorTestCase extends InternalBrokerBaseCase
super.tearDown();
}
+ public String sendTestLogMessage(LogActor actor)
+ {
+ String message = "Test logging: " + getName();
+ sendTestLogMessage(actor, message);
+
+ return message;
+ }
+
+ public void sendTestLogMessage(LogActor actor, final String message)
+ {
+ actor.message(new LogSubject()
+ {
+ public String toString()
+ {
+ return message;
+ }
+
+ }, new LogMessage()
+ {
+ public String toString()
+ {
+ return message;
+ }
+
+ public String getLogHierarchy()
+ {
+ return "test.hierarchy";
+ }
+ });
+ }
+
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java
index bfdf48337d..1b95d53702 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java
@@ -30,6 +30,4 @@ public class BaseConnectionActorTestCase extends BaseActorTestCase
_amqpActor = new AMQPConnectionActor(_session, _rootLogger);
}
-
-
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
index ae2ea5fb69..95a5610917 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
@@ -23,10 +23,7 @@ package org.apache.qpid.server.logging.actors;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.logging.LogMessage;
-import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.NullRootMessageLogger;
-import org.apache.qpid.server.registry.ApplicationRegistry;
/**
* Test : CurrentActorTest
@@ -92,20 +89,7 @@ public class CurrentActorTest extends BaseConnectionActorTestCase
CurrentActor.set(connectionActor);
//Use the Actor to send a simple message
- CurrentActor.get().message(new LogSubject()
- {
- public String toString()
- {
- return "[CurrentActorTest] ";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return "Connection Log Msg";
- }
- });
+ sendTestLogMessage(CurrentActor.get());
// Verify it was the same actor as we set earlier
assertEquals("Retrieved actor is not as expected ",
@@ -128,20 +112,7 @@ public class CurrentActorTest extends BaseConnectionActorTestCase
CurrentActor.set(channelActor);
//Use the Actor to send a simple message
- CurrentActor.get().message(new LogSubject()
- {
- public String toString()
- {
- return "[CurrentActorTest] ";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return "Channel Log Msg";
- }
- });
+ sendTestLogMessage(CurrentActor.get());
// Verify it was the same actor as we set earlier
assertEquals("Retrieved actor is not as expected ",
@@ -263,20 +234,7 @@ public class CurrentActorTest extends BaseConnectionActorTestCase
CurrentActor.set(actor);
//Use the Actor to send a simple message
- CurrentActor.get().message(new LogSubject()
- {
- public String toString()
- {
- return "[CurrentActorTest] ";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return "Running Thread:" + count;
- }
- });
+ sendTestLogMessage(CurrentActor.get());
// Verify it was the same actor as we set earlier
assertEquals("Retrieved actor is not as expected ",
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
index dec59487db..033ae3b4b3 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
@@ -71,22 +71,7 @@ public class ManagementActorTest extends BaseActorTestCase
*/
public void testConnection()
{
- final String message = "test logging";
-
- _amqpActor.message(new LogSubject()
- {
- public String toString()
- {
- return "[AMQPActorTest]";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return message;
- }
- });
+ final String message = sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java
index 703149a760..8cb74ab29b 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java
@@ -48,22 +48,7 @@ public class QueueActorTest extends BaseConnectionActorTestCase
*/
public void testQueueActor()
{
- final String message = "test logging";
-
- _amqpActor.message(new LogSubject()
- {
- public String toString()
- {
- return "[AMQPActorTest]";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return message;
- }
- });
+ final String message = sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
index c3f3d05549..d9246b13ec 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
@@ -20,14 +20,11 @@
*/
package org.apache.qpid.server.logging.actors;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import java.util.List;
+
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.subscription.MockSubscription;
-import org.apache.qpid.server.queue.MockAMQQueue;
-import org.apache.qpid.AMQException;
-
-import java.util.List;
/**
* Test : AMQPConnectionActorTest
@@ -63,22 +60,7 @@ public class SubscriptionActorTest extends BaseConnectionActorTestCase
*/
public void testSubscription()
{
- final String message = "test logging";
-
- _amqpActor.message(new LogSubject()
- {
- public String toString()
- {
- return "[AMQPActorTest]";
- }
-
- }, new LogMessage()
- {
- public String toString()
- {
- return message;
- }
- });
+ final String message = sendTestLogMessage(_amqpActor);
List<Object> logs = _rawLogger.getLogMessages();
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java b/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
index 9acbe72cb3..d3e762bdfa 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
@@ -20,23 +20,18 @@
*/
package org.apache.qpid.server.logging.messages;
-import junit.framework.TestCase;
+import java.util.List;
+
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.UnitTestMessageLogger;
import org.apache.qpid.server.logging.actors.TestLogActor;
-import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
import org.apache.qpid.server.logging.subjects.TestBlankSubject;
-import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import java.util.List;
-
public abstract class AbstractTestMessages extends InternalBrokerBaseCase
{
protected Configuration _config = new PropertiesConfiguration();
@@ -50,15 +45,9 @@ public abstract class AbstractTestMessages extends InternalBrokerBaseCase
{
super.setUp();
- ServerConfiguration serverConfig = new ServerConfiguration(_config);
-
- serverConfig.getConfig().setProperty(ServerConfiguration.STATUS_UPDATES, "on");
-
_logger = new UnitTestMessageLogger();
- RootMessageLogger rootLogger =
- new RootMessageLoggerImpl(serverConfig, _logger);
- _actor = new TestLogActor(rootLogger);
+ _actor = new TestLogActor(_logger);
}
protected List<Object> performLog()
@@ -84,6 +73,7 @@ public abstract class AbstractTestMessages extends InternalBrokerBaseCase
*/
protected void validateLogMessage(List<Object> logs, String tag, String[] expected)
{
+System.out.println("===============" + logs.get(0));
assertEquals("Log has incorrect message count", 1, logs.size());
//We trim() here as we don't care about extra white space at the end of the log message
diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
index 41fe81a717..025f899a6c 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
@@ -31,9 +31,9 @@ import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.RootMessageLogger;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.AbstractRootMessageLogger;
+import org.apache.qpid.server.logging.UnitTestMessageLogger;
import org.apache.qpid.server.logging.actors.TestLogActor;
-import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.util.InternalBrokerBaseCase;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -84,12 +84,9 @@ public abstract class AbstractTestLogSubject extends InternalBrokerBaseCase
}
ServerConfiguration serverConfig = new ServerConfiguration(_config);
+ UnitTestMessageLogger logger = new UnitTestMessageLogger(serverConfig);
- UnitTestMessageLogger logger = new UnitTestMessageLogger();
- RootMessageLogger rootLogger =
- new RootMessageLoggerImpl(serverConfig, logger);
-
- LogActor actor = new TestLogActor(rootLogger);
+ LogActor actor = new TestLogActor(logger);
actor.message(_subject, new LogMessage()
{
@@ -97,6 +94,11 @@ public abstract class AbstractTestLogSubject extends InternalBrokerBaseCase
{
return "<Log Message>";
}
+
+ public String getLogHierarchy()
+ {
+ return "test.hierarchy";
+ }
});
return logger.getLogMessages();
diff --git a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
index 99053ca45a..47b5b1c1c2 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
@@ -30,7 +30,7 @@ import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.logging.StartupRootMessageLogger;
+import org.apache.qpid.server.logging.SystemOutMessageLogger;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.exchange.Exchange;
@@ -76,7 +76,7 @@ public class InternalBrokerBaseCase extends QpidTestCase
protected void createBroker() throws Exception
{
_started = true;
- CurrentActor.set(new TestLogActor(new StartupRootMessageLogger()));
+ CurrentActor.set(new TestLogActor(new SystemOutMessageLogger()));
_configuration = new ServerConfiguration(_configXml);
diff --git a/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm b/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
index f0cbaf53a1..fd847fd513 100644
--- a/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
+++ b/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
@@ -20,6 +20,9 @@
*/
package ${package};
+import static org.apache.qpid.server.logging.AbstractRootMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX;
+
+import org.apache.log4j.Logger;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -42,9 +45,19 @@ public class ${type.name}Messages
{
static ResourceBundle _messages;
static Locale _currentLocale;
+
+ public static final String ${type.name.toUpperCase()}_LOG_HIERARCHY = DEFAULT_LOG_HIERARCHY_PREFIX + "${type.name.toLowerCase()}";
+#foreach( $message in ${type.list} )
+ public static final String ${message.methodName.toUpperCase()}_LOG_HIERARCHY = DEFAULT_LOG_HIERARCHY_PREFIX + "${type.name.toLowerCase()}.${message.methodName.toLowerCase()}";
+#end
static
{
+ Logger.getLogger(${type.name.toUpperCase()}_LOG_HIERARCHY);
+#foreach( $message in ${type.list} )
+ Logger.getLogger(${message.methodName.toUpperCase()}_LOG_HIERARCHY);
+#end
+
reload();
}
@@ -174,6 +187,11 @@ public class ${type.name}Messages
{
return message;
}
+
+ public String getLogHierarchy()
+ {
+ return ${message.methodName.toUpperCase()}_LOG_HIERARCHY;
+ }
};
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
index 816720e581..0a0186e865 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
@@ -63,7 +63,7 @@ public class AbstractTestLogging extends QpidBrokerTestCase
protected void createBroker() throws Exception
{
_started = true;
- CurrentActor.set(new TestLogActor(new StartupRootMessageLogger()));
+ CurrentActor.set(new TestLogActor(new SystemOutMessageLogger()));
// Prevent the InVM broker from logging and spoiling tests.
_serverConfiguration.getConfig().setProperty(ServerConfiguration.STATUS_UPDATES, "off");
diff --git a/java/test-profiles/log4j-test.xml b/java/test-profiles/log4j-test.xml
index 5ad277ea74..9adfd68202 100644
--- a/java/test-profiles/log4j-test.xml
+++ b/java/test-profiles/log4j-test.xml
@@ -39,6 +39,10 @@
<level value="${amqj.logging.level}"/>
</logger>
+ <logger name="qpid.message">
+ <level value="INFO"/>
+ </logger>
+
<logger name="qpid.protocol">
<level value="${amqj.protocol.logging.level}"/>
</logger>