QuietWriterpublic class QuietWriter extends FilterWriter QuietWriter does not throw exceptions when things go
wrong. Instead, it delegates error handling to its {@link ErrorHandler}. |
Fields Summary |
---|
protected ErrorHandler | errorHandler |
Constructors Summary |
---|
public QuietWriter(Writer writer, ErrorHandler errorHandler)
super(writer);
setErrorHandler(errorHandler);
|
Methods Summary |
---|
public void | flush()
try {
out.flush();
} catch(IOException e) {
errorHandler.error("Failed to flush writer,", e,
ErrorCode.FLUSH_FAILURE);
}
| public void | setErrorHandler(org.apache.log4j.spi.ErrorHandler eh)
if(eh == null) {
// This is a programming error on the part of the enclosing appender.
throw new IllegalArgumentException("Attempted to set null ErrorHandler.");
} else {
this.errorHandler = eh;
}
| public void | write(java.lang.String string)
try {
out.write(string);
} catch(IOException e) {
errorHandler.error("Failed to write ["+string+"].", e,
ErrorCode.WRITE_FAILURE);
}
|
|