Versions Compared

Key

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

...

Code Block
xml
xml
<broker>
 ...
  <status-updates>ON</status-updates>
 ...
</broker>

This INFO level status-update on setting will be the default value if the section is not included in the configuration file. The setting will be global for all virtualhosts and will be exposed via the management console as logger 'qpid.operationalstatus' to allow dynamic level setting.

The ability to configure more fine grained logging will be investigated here, but will not be implemented in the initial phase.

Logging Levels

The following six levels represent the range of levels that will be available as part of the logging configuration. Whilst the initial implementation may not include specific messages at each level this section simply describes the type of message that would appear at each level and the behaviour associated with logging at that level. The levels are listed in order of the frequency of logging events. In addition to these six levels the values ALL and OFF may be used, these respectively represent TRACE and FATAL. FATAL messages will always be logged as they are associated with a broker shutdown.

Status Updates

Status updates should take the form of general FATAL
Occurs when an unrecoverable error has occured.
e.g. Data corruption
ERROR
Occurs when a problem occurs in the system but it can generally continue to operate.
e.g. Unexpected error occurs that is limited to a single connection, i.e. not message store related.
WARN
Occurs when a potententialy harmful situation occurs.
e.g. Unexpected connection closure
INFO
General operational logging level, no logging on message delivery path way . and No performance impact. Recommended The recommendation will be to have these enabled for production use.
e.g. Creation/Destruction events
DEBUG
Additional logging on message delivery path way. May have performance impact. Not recommended for long term production use
e.g. Message Enqueue/Dequeue
TRACE Full delivery path debugging. Will have performance impact. Not intended for production use.
e.g. Message selector behaviour

Logging Abstraction

The abstraction layer allows us to fully decouple the logging mechanism from any operational logging that the broker may wish to perform. The following code highlights show how we would abstract the logging operations.

The approach to logging is that each Entitiy as highlighted on Logging Format Design would provide an implementation of MessageStatusLogger. This logger would be obtained from the MessagesStatusLoggerFactory during the constuction of the entity. When a Status event occured that should be logged a LogActor is requried to request the logging. The initial LogActors would be Connection, Channel and Subscription. Later phases would introduce VirtualHost and ManagementConnection. These Actors provide will initially only be used to provide their log display name as per the format design. However, later their details can be used to identify if logging should be procced for that Actor and Entity combination. At this stage selective configurations is not part of this design.

Code Block
java
java
titleOperationalLoggerLogActor


/**
 * LogActor the entity that is requesting the log to be peformed.
 *
 * The actor is responsible for providing the display name for the log entry.
 *
 */
public interface LogActor
{
    /**
     * Return the String that this actor wishes to be entered into the logfile.
     *
     * @return String
     */
    public String getLogFormatedName();
}
Code Block
java
java
titleMessageStatusLogger

/**
 * Message Status messages are logged via this interface.
 *
 * Each Entity that wishes to be logged will implement this to provide their
 * own display representation.
 *
 * The MSLogger will be created by a Factory {@see MessageStatusLoggerFactory}.
 *
 * The MessageFactory will maintain a reference to this Logger and will use the
 * #setEnabled() to determine if this logger should be operational.
 *
 * Currently logging has a global setting however this will later be revised and
 * as such the LogActor will need to be taken in to consideration as well as 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
{
    /**
     * Enable or disable this logger. As controlled by the MessageFactory.
     *
     * @param enabled boolean
     */
    public void setEnabled(boolean enabled);

    /**
     * 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.
     *
     * @param actor The actor that is requesting to perform logging
     *
     * @return if this log message should take place
     */
public interface OperationalLogger
{
    public boolean isInfoEnabledisMessageEnabled(LogEntityLogActor entity);
    public void info(LogEntity entity, Object message);
    public void info(LogEntity entity 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 requried 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).
     *
     * 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 requried 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(LogActor actor, Object message, Throwable throwable);
}

Code Block
java
java
titleMessageStatusLoggerFactory
/**
 * This interface provides a means of creating the Loggers that will be required
 * by each of the entities that have a desire to provide status updates.
 *
 * For new entities to support status logging this interface must be updated.
 *
 * All Loggers defer tot he RootMessageStatusLogger as to wither the log should
 * take place.
 */ Repeated for each level TRACE|DEBUG|INFO|WARN|ERROR|FATAL
}
public interface MessageStatusLoggerFactory
{
    public ConnectionMessageStatusLogger createConnectionMessageStatusLogger(AMQProtocolSession connection);

    public ChannelMessageStatusLogger createChannelMessageStatusLogger(AMQChannel channel);

    public QueueMessageStatusLogger createQueueMessageStatusLogger(AMQQueue queue);

    public ExchangeMessageStatusLogger createExchangeMessageStatusLogger(Exchange exchange);

    public BindingMessageStatusLogger createBindingMessageStatusLogger(ExchangeBinding binding);

    public SubscriptionMessageStatusLogger createSubscriptionMessageStatusLogger(Subscription subscription);

    public MessageStoreMessageStatusLogger createMessageStoreMessageStatusLogger(MessageStore store);
}

Code Block
java
java
titleLogEntityRootMessageStatusLogger

/**
 * The RootMessageStatusLogger is used by the MessageStatusLoggers to query if
 * logging is enabled for the requested message and to provide the actual
 * message that should be logged.
 */
public interface LogEntityRootMessageStatusLogger
{
    public String getLogPrefix();
    public void setCreator(LogEntity creator);
}

...

/**
     * Determins if the MessageStatusLogger and the LogActor should be
     * generating log messages.
     *
     * @param messageStatusLogger The logger performing the logging
     * @param actor               The actor requesting the logging
     * @return boolean true if the message should be logged.
     */
    boolean isMessageEnabled(MessageStatusLogger messageStatusLogger,
                             LogActor actor);

    /**
     * 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 resouce.
 */
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);
}

The addition of the ability to set a creator 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 INFO [ con:1(guest@127.0.0.1/)/ch:2/pl(ACL, Consume, qu(myQueue)) ] Plugin Event occured for this. 

Initial

...

FATAL

At this level it is only expected that broker/virtualhost wide components could cause a FATAL issue.

Broker
ManagementConsole
VirtualHost
MessageStore

MetaData not Found

ERROR

Broker

Startup errors

ManagementConsole

Startup errors
UserManagement notification(Create, Update, Delete)
Access Right modification/reload

VirtualHost
MessageStore

Recover errors

Connection

Unhandled exceptions leading to connection closure

Channel
Queue
Exchange
Binding
Subscription

WARN

Broker
ManagementConsole
VirtualHost
MessageStore
Connection

Unclean connection closure
Unsupported protocol version

Channel
Queue
Exchange
Binding
Subscription

INFO

Broker

Status Messages

Broker

Startup
Configuration details
Ready
Shutdown

ManagementConsole

Startup
Configuration details
Ready
Close

VirtualHost

Create
Configuration details
Close

MessageStore

Startup
Recover Status
Start
Progress
End
Close

Connection

Open
Close

Channel

Create
Flow Status
Destroy

Queue

Create
Destroy

Exchange

Create
Destroy

Binding

Create
Destroy

Subscription

Create
Destroy

DEBUG

Broker
ManagementConsole
VirtualHost

Message Expiry

MessageStore
Connection

Creation Configuration details

Channel

Acknowledge
Commit
MessageRejection

Queue

Enqueue
Dequeue

Exchange

Route

Binding
Subscription

Send/Add to prefetch/unacked map

TRACE

Broker
ManagementConsole
VirtualHost
MessageStore

Enqueue
Dequeue

Connection
Channel
Queue

Message State Change(Available->Aquire...)

Exchange
Binding

...