[prev in list] [next in list] [prev in thread] [next in thread]
List: log4j-dev
Subject: [jira] [Created] (LOG4J2-189) AsynchAppender: "blocking" parameter doesn't work
From: "Werner (JIRA)" <jira () apache ! org>
Date: 2013-03-30 1:41:15
Message-ID: JIRA.12639906.1364607570428.80150.1364607675605 () arcas
[Download RAW message or body]
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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic