org.apache.tomcat.util.log

Class SystemLogHandler

public class SystemLogHandler extends PrintStream

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

Field Summary
protected static ThreadLocallogs
Thread <-> CaptureLog associations.
protected PrintStreamout
Wrapped PrintStream.
protected static Stackreuse
Spare CaptureLog ready for reuse.
Constructor Summary
SystemLogHandler(PrintStream wrapped)
Construct the handler to capture the output of the given steam.
Method Summary
booleancheckError()
voidclose()
protected PrintStreamfindStream()
Find PrintStream to which the output must be written to.
voidflush()
voidprint(boolean b)
voidprint(char c)
voidprint(int i)
voidprint(long l)
voidprint(float f)
voidprint(double d)
voidprint(char[] s)
voidprint(String s)
voidprint(Object obj)
voidprintln()
voidprintln(boolean x)
voidprintln(char x)
voidprintln(int x)
voidprintln(long x)
voidprintln(float x)
voidprintln(double x)
voidprintln(char[] x)
voidprintln(String x)
voidprintln(Object x)
protected voidsetError()
static voidstartCapture()
Start capturing thread's output.
static StringstopCapture()
Stop capturing thread's output and return captured data as a String.
voidwrite(int b)
voidwrite(byte[] b)
voidwrite(byte[] buf, int off, int len)

Field Detail

logs

protected static ThreadLocal logs
Thread <-> CaptureLog associations.

out

protected PrintStream out
Wrapped PrintStream.

reuse

protected static Stack reuse
Spare CaptureLog ready for reuse.

Constructor Detail

SystemLogHandler

public SystemLogHandler(PrintStream wrapped)
Construct the handler to capture the output of the given steam.

Method Detail

checkError

public boolean checkError()

close

public void close()

findStream

protected PrintStream findStream()
Find PrintStream to which the output must be written to.

flush

public void flush()

print

public void print(boolean b)

print

public void print(char c)

print

public void print(int i)

print

public void print(long l)

print

public void print(float f)

print

public void print(double d)

print

public void print(char[] s)

print

public void print(String s)

print

public void print(Object obj)

println

public void println()

println

public void println(boolean x)

println

public void println(char x)

println

public void println(int x)

println

public void println(long x)

println

public void println(float x)

println

public void println(double x)

println

public void println(char[] x)

println

public void println(String x)

println

public void println(Object x)

setError

protected void setError()

startCapture

public static void startCapture()
Start capturing thread's output.

stopCapture

public static String stopCapture()
Stop capturing thread's output and return captured data as a String.

write

public void write(int b)

write

public void write(byte[] b)

write

public void write(byte[] buf, int off, int len)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.