Hi, All
Because of a bug already reported by me
(LOG4J2-246<https://issues.apache.org/jira/browse/LOG4J2-246>),
I had to write an Appender containing a fix/workaround.
Obvious approach for me would be inherittance from
AbstractOutputStreamAppender and overriding method append. However I
couldn't do that because:
manager.write(bytes); and
manager.flush(); are package visible only + few other visibility issues.
So I would suggest to use more protected visibility than package as well as
'template method' pattern, especially in classes like
AbstractOutputStreamAppender.
In order to finalize my story I have to say that the final solution was to
put
a copied AbstractOutputStreamAppender and new Appender in namespace
org.apache..... which is definitely not nice.
So, can you please consider making changes that would make lives of
extensions writers a little bit easier ?
Regards,
Tomek
-------------------------------------------------
@Override
public void append(final LogEvent event) {
final byte[] bytes = getLayout().toByteArray(event);
boolean failedOnSize = false;
readLock.lock();
try {
if (bytes.length > 0) {
if (bytes.length <= udpSizeLimit) {
manager.write(bytes);
if (this.immediateFlush || event.isEndOfBatch()) {
manager.flush();
}
} else {
failedOnSize = true;
}
}
} catch (final AppenderRuntimeException ex) {
error("Unable to write to stream " + manager.getName() + " for
appender " + getName());
throw ex;
} finally {
readLock.unlock();
}
if (failedOnSize) {
handleFailedSize(event, bytes);
}
}----------------------------------------------