Werner created LOG4J2-189: ------------------------------ Summary: AsynchAppender: "blocking" parameter doesn't work Key: LOG4J2-189 URL: https://issues.apache.org/jira/browse/LOG4J2-189 Project: Log4j 2 Issue Type: Bug Components: Appenders Affects Versions: 2.0-beta4 Reporter: Werner
AsynchAppender parameter: blocking=false ==> LogEvents are never distributed to other appenders blocking=true ==> the appender don't blocks if the queue is full proposal for solution: AsynchAppender.java public void append(final LogEvent event) { if (!isStarted()) { throw new IllegalStateException("AsynchAppender " + getName() + " is not active"); } if (event instanceof Log4jLogEvent) { // if (blocking && queue.remainingCapacity() > 0) { // try { // queue.add(Log4jLogEvent.serialize((Log4jLogEvent) event)); // return; // } catch (final IllegalStateException ex) { // error("Appender " + getName() + " is unable to write primary appenders. queue is full"); // } // } // if (errorAppender != null) { // if (!blocking) { // error("Appender " + getName() + " is unable to write primary appenders. queue is full"); // } // errorAppender.callAppender(event); // } boolean appendSuccessful = false; if (blocking){ try { queue.put(Log4jLogEvent.serialize((Log4jLogEvent) event)); // wait for free slots in the queue appendSuccessful = true; } catch (InterruptedException e) { LOGGER.warn("Interrupted while waiting for a free slots in the LogEvent-queue at the AsynchAppender {}", getName()); } }else{ appendSuccessful = queue.offer(Log4jLogEvent.serialize((Log4jLogEvent) event)); if (!appendSuccessful){ error("Appender " + getName() + " is unable to write primary appenders. queue is full"); } } if ((!appendSuccessful) && (errorAppender != null)){ errorAppender.callAppender(event); } } } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org