Package com.linkedin.venice.utils
Class LogContext
java.lang.Object
com.linkedin.venice.utils.LogContext
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
.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LogContext
static final String
Key used in the logging context (e.g., ThreadContext/MDC) to tag log lines with the component and region name. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
getValue()
static LogContext.Builder
static void
setLogContext
(Object logContext) static void
setRegionLogContext
(String regionName) Updates the ThreadContext (MDC) with a logging context derived from the given region name.static void
setStructuredLogContext
(LogContext logContext) toString()
Returns a formatted string representation of the log context in the form:componentName|regionName
.
-
Field Details
-
EMPTY
-
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
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
-
setLogContext
-
clearLogContext
public static void clearLogContext() -
getRegionName
- Returns:
- The region name stored in this LogContext.
-
getComponentName
- Returns:
- The component name stored in this LogContext.
-
getValue
- Returns:
- The value of the log context in the form
componentName|regionName
.
-
toString
Returns a formatted string representation of the log context in the form:componentName|regionName
. -
newBuilder
- Returns:
- A new builder for constructing
LogContext
instances.
-