log4j2 configure global asynchronous log startup parameter is used Log4jContextSelector how to use the disruptor

And log4j2 configuration asynchronous log with asyncRoot how to use the disruptor There are a few differences:

Different instances to EventFactory disruptor

Is used herein EventFactory RingBufferLogEvent.FACTORY, newInstance logic is roughly:

public RingBufferLogEvent newInstance() {
    final RingBufferLogEvent result = new RingBufferLogEvent();
    if (Constants.ENABLE_THREADLOCALS) {
        result.messageText = new StringBuilder(Constants.INITIAL_REUSABLE_MESSAGE_SIZE);
        result.parameters = new Object[10];
    }
    return result;
}

Creating an RingBufferLogEventinstance. The action object encapsulates perform log output or the like.

To the disruptor of different parameters threadFactory

thread factory name is "AsyncLogger [" + contextName + "]"

EventHandler disruptor to different

Here with RingBufferLogEventHandler, docking RingBufferLogEvent instance logs write.

Translator's different to disrupto

Here with RingBufferLogEventTranslator, docking assembly RingBufferLogEvent instance log information.

Events queued in different ways

TryPublish packaging method called a queue entry.

Guess you like

Origin www.cnblogs.com/simoncook/p/10990266.html