org.apache.log4j.helpers
public class: QuietWriter [javadoc |
source]
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.apache.log4j.helpers.QuietWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable
Direct Known Subclasses:
CountingQuietWriter, SyslogQuietWriter
QuietWriter does not throw exceptions when things go
wrong. Instead, it delegates error handling to its
ErrorHandler .
- author:
Ceki - Gülcü
- since:
0.7.3 -
| Field Summary |
|---|
| protected ErrorHandler | errorHandler | |
| Methods from java.io.Writer: |
|---|
|
append, append, append, append, append, append, close, flush, write, write, write, write, write |
| Method from org.apache.log4j.helpers.QuietWriter Detail: |
public void flush() {
try {
out.flush();
} catch(IOException e) {
errorHandler.error("Failed to flush writer,", e,
ErrorCode.FLUSH_FAILURE);
}
}
|
public void setErrorHandler(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(String string) {
try {
out.write(string);
} catch(IOException e) {
errorHandler.error("Failed to write ["+string+"].", e,
ErrorCode.WRITE_FAILURE);
}
}
|