Class 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.
    • Constructor Detail

      • NodeAndClusterIdConverter

        public NodeAndClusterIdConverter()
    • Method Detail

      • setNodeIdAndClusterId

        public static void setNodeIdAndClusterId​(String nodeId,
                                                 String clusterUUID)
        Updates only once the clusterID and nodeId. Subsequent executions will throw SetOnce.AlreadySetException.
        Parameters:
        nodeId - a nodeId received from cluster state update
        clusterUUID - a clusterId received from cluster state update
      • format

        public void format​(org.apache.logging.log4j.core.LogEvent event,
                           StringBuilder toAppendTo)
        Formats the node.id and cluster.uuid into json fields.
        Specified by:
        format in class org.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