Package com.google.cloud.hadoop.util
Class LoggingFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- com.google.cloud.hadoop.util.LoggingFormatter
-
public class LoggingFormatter extends Formatter
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
Constructors Constructor Description LoggingFormatter(Formatter existingFormatter)Constructs a new LoggingFormatter that wraps an existing formatter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddFormatter(Logger logger)Adds the custom logging formatter to all handlers of the given logger.Stringformat(LogRecord record)Formats the given log record by prefixing it with the invocation ID.-
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
-
-
-
Constructor Detail
-
LoggingFormatter
public LoggingFormatter(Formatter existingFormatter)
Constructs a new LoggingFormatter that wraps an existing formatter.- Parameters:
existingFormatter- The formatter to be decorated.
-
-
Method Detail
-
format
public String format(LogRecord record)
Formats the given log record by prefixing it with the invocation ID.
-
addFormatter
public static void addFormatter(Logger logger)
Adds the custom logging formatter to all handlers of the given logger.- Parameters:
logger- the logger to which the formatter will be added
-
-