Class SystemLogHandler
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
org.apache.tomcat.util.log.SystemLogHandler
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
This helper class may be used to do sophisticated redirection of System.out and System.err on a per Thread basis. A
stack is implemented per Thread so that nested startCapture and stopCapture can be used.
- Author:
- Remy Maucherat, Glenn L. Nielsen
-
Constructor Summary
ConstructorsConstructorDescriptionSystemLogHandler(PrintStream wrapped) Construct the handler to capture the output of the given steam. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose()protected PrintStreamFind PrintStream to which the output must be written to.voidflush()voidprint(boolean b) voidprint(char c) voidprint(char[] s) voidprint(double d) voidprint(float f) voidprint(int i) voidprint(long l) voidvoidvoidprintln()voidprintln(boolean x) voidprintln(char x) voidprintln(char[] x) voidprintln(double x) voidprintln(float x) voidprintln(int x) voidprintln(long x) voidvoidprotected voidsetError()static voidStart capturing thread's output.static StringStop capturing thread's output.voidwrite(byte[] b) voidwrite(byte[] buf, int off, int len) voidwrite(int b) Methods inherited from class java.io.PrintStream
append, append, append, charset, clearError, format, format, printf, printf, writeBytesMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
SystemLogHandler
Construct the handler to capture the output of the given steam.- Parameters:
wrapped- The stream to capture
-
-
Method Details
-
startCapture
public static void startCapture()Start capturing thread's output. -
stopCapture
-
findStream
Find PrintStream to which the output must be written to.- Returns:
- the print stream
-
flush
public void flush()- Specified by:
flushin interfaceFlushable- Overrides:
flushin classPrintStream
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classPrintStream
-
checkError
public boolean checkError()- Overrides:
checkErrorin classPrintStream
-
setError
protected void setError()- Overrides:
setErrorin classPrintStream
-
write
public void write(int b) - Overrides:
writein classPrintStream
-
write
- Overrides:
writein classPrintStream- Throws:
IOException
-
write
public void write(byte[] buf, int off, int len) - Overrides:
writein classPrintStream
-
print
public void print(boolean b) - Overrides:
printin classPrintStream
-
print
public void print(char c) - Overrides:
printin classPrintStream
-
print
public void print(int i) - Overrides:
printin classPrintStream
-
print
public void print(long l) - Overrides:
printin classPrintStream
-
print
public void print(float f) - Overrides:
printin classPrintStream
-
print
public void print(double d) - Overrides:
printin classPrintStream
-
print
public void print(char[] s) - Overrides:
printin classPrintStream
-
print
- Overrides:
printin classPrintStream
-
print
- Overrides:
printin classPrintStream
-
println
public void println()- Overrides:
printlnin classPrintStream
-
println
public void println(boolean x) - Overrides:
printlnin classPrintStream
-
println
public void println(char x) - Overrides:
printlnin classPrintStream
-
println
public void println(int x) - Overrides:
printlnin classPrintStream
-
println
public void println(long x) - Overrides:
printlnin classPrintStream
-
println
public void println(float x) - Overrides:
printlnin classPrintStream
-
println
public void println(double x) - Overrides:
printlnin classPrintStream
-
println
public void println(char[] x) - Overrides:
printlnin classPrintStream
-
println
- Overrides:
printlnin classPrintStream
-
println
- Overrides:
printlnin classPrintStream
-