- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
LoggingPrintStream has it's own LoggingOutputStream.
Once it is set as the System.out or System.err, all outputs to these
PrintStreams will end up in LoggingOutputStream which will log these on a flush.
This simple behaviour has a negative side effect that stack traces are logged with
each line being a new log record. The reason for above is that
Throwable.printStackTrace(PrintStream) converts each
line into a separate println, causing a flush at the end of each.
One option that was thought of to smooth this over was to see if the caller of println is
Throwable.[some set of methods]. Unfortunately, there are others who
interpose on System.out and err (like jasper) which makes that check untenable.
Hence the logic currently used is to see if there is a println(Throwable)
and create a standard log record of it and then prevent subsequent printline calls
done by the Throwable.printStackTrace(PrintStream) method.
This is possible because Throwable locks the stream to avoid collisions.
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggingPrintStreamvoidprintln()voidvoidtoString()voidwrite(byte[] buf, int off, int len) Methods inherited from class java.io.PrintStream
append, append, append, checkError, clearError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, setError, write, write, writeBytesMethods inherited from class java.io.OutputStream
nullOutputStream
-
Method Details
-
create
public static LoggingPrintStream create(Logger logger, Level level, int bufferCapacity, Charset charset) -
println
- Overrides:
printlnin classPrintStream
-
printf
- Overrides:
printfin classPrintStream
-
printf
- Overrides:
printfin classPrintStream
-
format
- Overrides:
formatin classPrintStream
-
format
- Overrides:
formatin classPrintStream
-
println
public void println()- Overrides:
printlnin classPrintStream
-
println
- Overrides:
printlnin classPrintStream
-
write
public void write(byte[] buf, int off, int len) - Overrides:
writein classPrintStream
-
toString
-