java.lang.Object
java.io.OutputStream
org.elasticsearch.common.logging.ChunkedLoggingStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An
OutputStream
which Gzip-compresses the written data, Base64-encodes it, and writes it in fixed-size chunks to a logger. This
is useful for debugging information that may be too large for a single log message and/or which may include data which cannot be
recorded faithfully in plain-text (e.g. binary data or data with significant whitespace).-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static OutputStream
create
(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level level, String prefix, ReferenceDocs referenceDocs) Create anOutputStream
which Gzip-compresses the written data, Base64-encodes it, and writes it in fixed-size (2kiB) chunks to the given logger.void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Method Details
-
create
public static OutputStream create(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level level, String prefix, ReferenceDocs referenceDocs) throws IOException Create anOutputStream
which Gzip-compresses the written data, Base64-encodes it, and writes it in fixed-size (2kiB) chunks to the given logger. If the data fits into a single chunk then the output looks like this:$PREFIX (gzip compressed and base64-encoded; for details see ...): H4sIAAAAA...
If there are multiple chunks then they are written like this:$PREFIX [part 1]: H4sIAAAAA... $PREFIX [part 2]: r38c4MBHO... $PREFIX [part 3]: ECyRFONaL... $PREFIX [part 4]: kTgm+Qswm... $PREFIX (gzip compressed, base64-encoded, and split into 4 parts on preceding log lines; for details see ...)
- Parameters:
logger
- The logger to receive the chunks of data.level
- The log level to use for the logging.prefix
- A prefix for each chunk, which should be reasonably unique to allow for reconstruction of the original message even if multiple such streams are used concurrently.referenceDocs
- A link to the relevant reference docs to help users interpret the output. Relevant reference docs are required because the output is rather human-unfriendly and we need somewhere to describe how to decode it.- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-