Class TraceLoggingEventEnhancer

java.lang.Object
com.google.cloud.logging.logback.TraceLoggingEventEnhancer
All Implemented Interfaces:
LoggingEventEnhancer

public class TraceLoggingEventEnhancer extends Object implements LoggingEventEnhancer
Adds support for grouping logs by incoming http request
  • Constructor Details

    • TraceLoggingEventEnhancer

      public TraceLoggingEventEnhancer()
  • 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]
    • clearTraceId

      public static void clearTraceId()
      Clearing a trace Id from the MDC
    • getCurrentTraceId

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

      public void enhanceLogEntry(com.google.cloud.logging.LogEntry.Builder builder, ch.qos.logback.classic.spi.ILoggingEvent e)
      Specified by:
      enhanceLogEntry in interface LoggingEventEnhancer