FileDocCategorySizeDatePackage
QuietWriter.javaAPI DocApache log4j 1.2.152083Sat Aug 25 00:09:40 BST 2007org.apache.log4j.helpers

QuietWriter

public class QuietWriter extends FilterWriter
QuietWriter does not throw exceptions when things go wrong. Instead, it delegates error handling to its {@link ErrorHandler}.
author
Ceki Gülcü
since
0.7.3

Fields Summary
protected ErrorHandler
errorHandler
Constructors Summary
public QuietWriter(Writer writer, ErrorHandler errorHandler)

    super(writer);
    setErrorHandler(errorHandler);
  
Methods Summary
public voidflush()

    try {
      out.flush();
    } catch(IOException e) {
      errorHandler.error("Failed to flush writer,", e, 
			 ErrorCode.FLUSH_FAILURE);
    }	
  
public voidsetErrorHandler(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 voidwrite(java.lang.String string)

    try {
      out.write(string);
    } catch(IOException e) {
      errorHandler.error("Failed to write ["+string+"].", e, 
			 ErrorCode.WRITE_FAILURE);
    }