Class LogContext

java.lang.Object
com.linkedin.venice.utils.LogContext

public class LogContext extends Object
Utility class representing structured logging context information, such as component and region name. Used to enrich log messages with identifying context via Log4j2's ThreadContext.
  • Field Details

    • EMPTY

      public static final LogContext EMPTY
    • LOG_CONTEXT_KEY

      public static final String LOG_CONTEXT_KEY
      Key used in the logging context (e.g., ThreadContext/MDC) to tag log lines with the component and region name. Helps disambiguate log output in multi-cluster or multi-component test setups.
      See Also:
  • Method Details

    • setRegionLogContext

      public static void setRegionLogContext(String regionName)
      Updates the ThreadContext (MDC) with a logging context derived from the given region name. If the region name is blank or null, no update is performed.
      Parameters:
      regionName - The name of the region to include in the log context.
    • setStructuredLogContext

      public static void setStructuredLogContext(@Nullable LogContext logContext)
    • setLogContext

      public static void setLogContext(Object logContext)
    • clearLogContext

      public static void clearLogContext()
    • getRegionName

      public String getRegionName()
      Returns:
      The region name stored in this LogContext.
    • getComponentName

      public String getComponentName()
      Returns:
      The component name stored in this LogContext.
    • getValue

      public String getValue()
      Returns:
      The value of the log context in the form componentName|regionName.
    • toString

      public String toString()
      Returns a formatted string representation of the log context in the form: componentName|regionName.
      Overrides:
      toString in class Object
    • newBuilder

      public static LogContext.Builder newBuilder()
      Returns:
      A new builder for constructing LogContext instances.