Class GcpJsonFormatter

java.lang.Object
java.util.logging.Formatter
google.registry.util.GcpJsonFormatter

public class GcpJsonFormatter extends Formatter
JUL formatter that formats log messages in a single-line JSON that Stackdriver logging can parse.

The structured logs written to STDOUT and STDERR will be picked up by GAE/GKE logging agent and automatically ingested by Stackdriver. Certain fields (see below) in the JSON will be converted to the corresponding Log Entry fields and parsed by Log Explorer.

See Also:
  • Constructor Details

    • GcpJsonFormatter

      public GcpJsonFormatter()
  • Method Details

    • setCurrentTraceId

      public static void setCurrentTraceId(String id)
      Set the Trace ID associated with any logging done by the current thread.
      Parameters:
      id - The traceID, in the form projects/[PROJECT_ID]/traces/[TRACE_ID]
    • getCurrentTraceId

      public static String getCurrentTraceId()
      Get the Trace ID associated with any logging done by the current thread.
      Returns:
      id The traceID
    • format

      public String format(LogRecord record)
      Specified by:
      format in class Formatter