This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The approach to logging is that each Entitiy as a LogActor will be recoreded as a ThreadLocal and will be used to perform logging the log messages as highlighted on Logging Format Design would provide an implementation of MessageStatusLogger. This logger would be obtained from the MessagesStatusLoggerFactory during the construction of the entity. The LogActor will take two parameters, the LogSubject and the LogMessage. When a Status event occurred occurs that should be logged a LogActor is required to request the logging. The initial _LogActor_s would be Connection, Channel and Subscriptionthe LogActor can be retrieved from the thread thus avoiding passing the LogActor through as a parameter to all locations were it must be logged. The initial LogActors will be AMQPActor and ManagementActor. Later phases would introduce VirtualHost and ManagementConnection. These Actors will initially only be used to provide HouseKeepingActor. These LogActors are responsible for checking that the logging should be performed for both themselves and the LogSubject. The LogActor then provids their log formatted name as per the format design. However, later their along with the message to the RootMessageLogger. Initially the configuration will be a simple on/off, however, in a future phase the details can be used to identify if logging should proceed for that Actor LogActor and Entity LogSubject combination. At this stage selective configurations is not part of this design.

The addition use of the LogActor allows for situations such as Binding to have a Connection associated with the Binding. This will allow a Binding create event to be logged like this:

No Format
2009-06-29 13:35:10,1234 +0100 MESSAGE [ con:1(guest@127.0.0.1/)/ch:2/] [ex(amq.direct)/qu(testQueue)/bd(routingKey) ] BND-1001 : Binding Created

...

No Format
2009-06-29 13:35:10,1234 +0100 MESSAGE [ vh(/)/ex(amq.direct)/qu(testQueue)/bd(routingKey) ] BDN-1001 : BindingCreate
Created

Interfaces

Code Block
java
java
titleLogActor

/**
 * LogActor the entity that is requestingstored theas log in a ThreadLocal and used to beperform performedlogging.
 *
 * The actor is responsible for providingformatting theits formatteddisplay name for the log entry.
 * 
*/ public interface LogActor
{
    /** The actor performs   * Return the String that this actor wishes to be entered into the logfilerequested logging.
     *
     * @return String
     */
public interface LogActor
{
public String getLogFormattedName(); } 
Code Block
javajava
titleMessageStatusLogger

/**
 * Message Status messages are logged via this interface.
 * Logs *the Eachspecified EntityLogMessage thatabout wishesthe toLogSubject
be logged will implement this to provide their
 *
own display representation.  *  * The MSLogger will be created by a Factory {@see MessageStatusLoggerFactory}.
 *
 * Currently logging has a global setting however this will later be revised and
     * as such the LogActor will need to betake takeninto in to consideration asany wellnew asconfiguration the
 * status of this Logger.
 *  * A detailed and published list of messages that will be logged will be
 * provided so that monitoring systems can know what to expect.
 */
public interface MessageStatusLogger
{

    /**
     * This method should be used as a guard against expensive message
     * construction prior to calling message().
     *
     * It should not be called if there is no construction required.
     *
     * This will perform validation that the log message should be performed
     * based on the provided Actor and the Entity this Logger represents.
     * This may be done via delegation to the RootMessageStatusLogger.
     *
     * @param actor The actor that is requesting to perform logging
     *
     * @return if this log message should take place
     */
    public boolean isMessageEnabled(LogActor actor);

    /**
     * Logs the message as provided by String.valueOf(message).
     *
     * The call to message() will first check if #isMessageEnabled() allows
     * the logging to be performed. This means for simple messages it is not
     * necessary to guard this call with isMessageEnabled() as it will be called
     * internally.
     *
     * If any complex construction is required then it MUST BE guarded so that
     * the log message is not needlessly generated.
     *
     * @param actor   The actor that is requesting the logging
     * @param message The message to log
     */
    public void message(LogActor actor, Object message);

    /**
     * Logs the message as provided by String.valueOf(message).means of enabling the logging of LogActors and LogSubjects.
     *
     * The call to message() will first check if #isMessageEnabled() allows
     * the logging to be performed. This means for simple messages it is not
     * necessary to guard this call with isMessageEnabled() as it will be called
     * internally.
     *
     * If any complex construction is required then it MUST BE guarded so that
     * the log message is not needlessly generated.
     *
     * If the provided Throwable is non-null then the stack trace will also be
     * logged.
     *
     * @param actor   The actor that is requesting the logging
     * @param message The message to log
     * @param throwable The throwable that should be used to generate a trace.
     */
    public void message(LogActorLogSubject actorsubject, ObjectLogMessage message, Throwable throwable);
}

Code Block
java
java
titleMessageStatusLoggerFactoryLogSubject
/**
 * ThisEach interfaceLogSubject providesthat awishes meansto ofbe creating the Loggers that logged will beimplement required
 * by each of the entities that have a desire this to provide statustheir
updates.  * own * For new entities to support status logging this interface must be updateddisplay representation.
 * 
 * AllThe Loggersdisplay deferrepresentation tois theretrieved RootMessageStatusLogger as to wither through the log should
 * take placetoString() method.
 */
public interface MessageStatusLoggerFactoryLogSubject
{
    public/**
ConnectionMessageStatusLogger createConnectionMessageStatusLogger(AMQProtocolSession connection);   * Logs the publicmessage ChannelMessageStatusLoggeras createChannelMessageStatusLogger(AMQChannel channel);

    public QueueMessageStatusLogger createQueueMessageStatusLogger(AMQQueue queue);provided by String.valueOf(message).
     public*
ExchangeMessageStatusLogger createExchangeMessageStatusLogger(Exchange exchange);   * @returns String publicthe BindingMessageStatusLoggerdisplay createBindingMessageStatusLogger(ExchangeBinding binding);

representation of this LogSubject
   public SubscriptionMessageStatusLogger createSubscriptionMessageStatusLogger(Subscription subscription);*/
      public MessageStoreMessageStatusLoggerString createMessageStoreMessageStatusLoggertoString(MessageStore store);
}

Code Block
java
java
titleRootMessageStatusLoggerRootMessageLogger
/**
 * The RootMessageStatusLoggerRootMessageLogger is used by the MessageStatusLoggersLogActors to query if
 * logging is enabled for the requested message and to provide the actual
 * message that should be logged.
 */
public interface RootMessageStatusLoggerRootMessageLogger
{
    /**
     * DeterminDetermine if the MessageStatusLoggerLogSubject and the LogActor should be
     * generating log messages.
     *
     * @param messageStatusLoggerlogSubject The loggersubject performingof thethis logginglog request
     * @param actorlogActor               The actor requesting the logging
     * @return boolean true if the message should be logged.
     */
    boolean isMessageEnabled(MessageStatusLoggerLogActor messageStatusLoggeractor,                              LogActor actorLogSubject subject);

    /**
     * Log the raw message to the configured logger.
     *
     * @param message   The message to log
     * @param throwable Optional Throwable that should provide stact trace
     */
    void rawMessage(String message, Throwable throwable);

    /**
     * Accessor to get the MSLFactory that can then be used to perform logging 
     * @return MessageStatusLoggerFactory 
     */
    MessageStatusLoggerFactory getMessageStatusLoggerFactory();
}

Code Block
java
java
titleRawMessageLogger
/**
 * A RawMessage Logger takes the given String and any Throwable and writes the
 * data to its resource.
 */
public interface RawMessageLogger
{
    /**
     * 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);
}

...

Code Block
java
java
titleLogging of a Channel Creation
pubic class ChannelConnection
...
   LogActor if (_statusLogger.isInfoEnabled(cnnectonLogActor))amqpActor = // retrieved from ThreadLocal.
   //_channelSubject {is an instance LogSubject that knows how to  _statusLogger.info(connectonLogActorrepresent this Connection
   amqpActor.logMessage(_connectionSubject, LogMessages.CHANNEL_CREATE(this));

   }
...

Would result in the following based on the Logging Format Design.

No Format
2009-06-29 13:35:10,1234 +0100 MESSAGE [ con:1(guest@127.0.0.1/)/] [ch:2 ] ChM-1001 : Channel Created
Code Block
java
java
titleLogging of a new consumer creation
...
    if (_statusLogger.isInfoEnabled(subscriberActor))     {
        _statusLogger.info(subscriberActoramqpActor.logMessage(_subsriptionSubject, LogMessages.SUBSCRIPTION_CREATE(this));
    }
...

Would result in the following:

No Format
2009-06-29 13:35:10,1234 +0100 MESSAGE [ con:1(guest@127.0.0.1/)/ch:2/] [sub:1:qu(myqueue) ] Sub-1001 : Subscription Created

...