org.milyn.util
Class StdoutToLog4jFilter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.FilterWriter
          extended by org.milyn.util.StdoutToLog4jFilter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class StdoutToLog4jFilter
extends FilterWriter

StoutToLog4jFilter is just a simple FileWriter implementation that supresses output unless the log4j priority is set to debug. This class in indended to be used with hsql embedded server and to be used like this:

Log targetLogger = LogFactory.getLog("org.hsqldb");
 server.setLogWriter(new PrintWriter(new StdoutToLog4jFilter(server.getLogWriter(), targetLogger)));
 
 

Author:
Daniel Bevenius

Field Summary
protected  org.apache.commons.logging.Log logger
          Log to log check logging level.
protected  StringBuilder sb
          string "buffer"
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
StdoutToLog4jFilter(Writer writer)
           
StdoutToLog4jFilter(Writer writer, org.apache.commons.logging.Log log)
           
 
Method Summary
 void close()
           
protected  void finalize()
           
 void flush()
           
protected  void log()
           
protected  void stripExtraNewLine()
           
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 void write(String str, int off, int len)
           
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.commons.logging.Log logger
Log to log check logging level.


sb

protected StringBuilder sb
string "buffer"

Constructor Detail

StdoutToLog4jFilter

public StdoutToLog4jFilter(Writer writer)

StdoutToLog4jFilter

public StdoutToLog4jFilter(Writer writer,
                           org.apache.commons.logging.Log log)
Method Detail

write

public void write(int c)
           throws IOException
Overrides:
write in class FilterWriter
Throws:
IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterWriter
Throws:
IOException

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterWriter
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class FilterWriter
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FilterWriter
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

log

protected void log()

stripExtraNewLine

protected final void stripExtraNewLine()


Copyright © 2018. All rights reserved.