Package com.google.cloud.hadoop.util
Class LoggingFormatter
java.lang.Object
java.util.logging.Formatter
com.google.cloud.hadoop.util.LoggingFormatter
A custom logging formatter that prefixes log messages with an invocation ID. If the log message
is in JSON format, the invocation ID is not prefixed.
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingFormatter(Formatter existingFormatter) Constructs a new LoggingFormatter that wraps an existing formatter. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddFormatter(Logger logger) Adds the custom logging formatter to all handlers of the given logger.Formats the given log record by prefixing it with the invocation ID.Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
Constructor Details
-
LoggingFormatter
Constructs a new LoggingFormatter that wraps an existing formatter.- Parameters:
existingFormatter- The formatter to be decorated.
-
-
Method Details
-
format
Formats the given log record by prefixing it with the invocation ID. -
addFormatter
Adds the custom logging formatter to all handlers of the given logger.- Parameters:
logger- the logger to which the formatter will be added
-