You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2019/05/23 01:38:22 UTC

[GitHub] [logging-log4j2] remkop commented on a change in pull request #273: LOG4J2-2606: Substantially improve async logging performance under heavy load

remkop commented on a change in pull request #273: LOG4J2-2606: Substantially improve async logging performance under heavy load
URL: https://github.com/apache/logging-log4j2/pull/273#discussion_r286747384
 
 

 ##########
 File path: log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
 ##########
 @@ -202,32 +209,95 @@ private boolean hasLog4jBeenShutDown(final Disruptor<RingBufferLogEvent> aDisrup
         return false;
     }
 
-    public boolean tryPublish(final RingBufferLogEventTranslator translator) {
+    boolean tryPublish(final RingBufferLogEventTranslator translator) {
         try {
+            // Note: we deliberately access the volatile disruptor field afresh here.
+            // Avoiding this and using an older reference could result in adding a log event to the disruptor after it
+            // was shut down, which could cause the publishEvent method to hang and never return.
             return disruptor.getRingBuffer().tryPublishEvent(translator);
         } catch (final NullPointerException npe) {
             // LOG4J2-639: catch NPE if disruptor field was set to null in stop()
-            LOGGER.warn("[{}] Ignoring log event after log4j was shut down: {} [{}] {}", contextName,
-                    translator.level, translator.loggerName, translator.message.getFormattedMessage()
-                            + (translator.thrown == null ? "" : Throwables.toStringList(translator.thrown)));
+            logWarningOnNpeFromDisruptorPublish(translator);
             return false;
         }
     }
 
-    void enqueueLogMessageInfo(final RingBufferLogEventTranslator translator) {
+    void enqueueLogMessageQueueFullBlocking(final RingBufferLogEventTranslator translator) {
 
 Review comment:
   I would suggest to remove "Blocking" from the method name; whether it actually blocks depends on configuration.
   I do like that you added "queue full" to the method name, that is informative.
   What about `enqueueLogMessageWhenQueueFull`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services