Package org.elasticsearch.common.logging
Class NodeAndClusterIdConverter
java.lang.Object
org.apache.logging.log4j.core.pattern.AbstractPatternConverter
org.apache.logging.log4j.core.pattern.LogEventPatternConverter
org.elasticsearch.common.logging.NodeAndClusterIdConverter
- All Implemented Interfaces:
org.apache.logging.log4j.core.pattern.PatternConverter
@Plugin(category="Converter",
name="NodeAndClusterIdConverter")
public final class NodeAndClusterIdConverter
extends org.apache.logging.log4j.core.pattern.LogEventPatternConverter
Pattern converter to format the node_and_cluster_id variable into JSON fields
node.id and cluster.uuid.
Keeping those two fields together assures that they will be atomically set and become visible in logs at the same time.-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
LOGGERFields inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter
CATEGORY -
Constructor Summary
Constructors Constructor Description NodeAndClusterIdConverter() -
Method Summary
Modifier and Type Method Description voidformat(org.apache.logging.log4j.core.LogEvent event, java.lang.StringBuilder toAppendTo)Formats the node.id and cluster.uuid into json fields.static NodeAndClusterIdConverternewInstance(java.lang.String[] options)Called by log4j2 to initialize this converter.static voidsetNodeIdAndClusterId(java.lang.String nodeId, java.lang.String clusterUUID)Updates only once the clusterID and nodeId.Methods inherited from class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
format, handlesThrowable, isVariableMethods inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter
getName, getStyleClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
NodeAndClusterIdConverter
public NodeAndClusterIdConverter()
-
-
Method Details
-
newInstance
Called by log4j2 to initialize this converter. -
setNodeIdAndClusterId
public static void setNodeIdAndClusterId(java.lang.String nodeId, java.lang.String clusterUUID)Updates only once the clusterID and nodeId. Subsequent executions will throwSetOnce.AlreadySetException.- Parameters:
nodeId- a nodeId received from cluster state updateclusterUUID- a clusterId received from cluster state update
-
format
public void format(org.apache.logging.log4j.core.LogEvent event, java.lang.StringBuilder toAppendTo)Formats the node.id and cluster.uuid into json fields.- Specified by:
formatin classorg.apache.logging.log4j.core.pattern.LogEventPatternConverter- Parameters:
event- - a log event is ignored in this method as it uses the nodeId and clusterId to format
-