Fork me on GitHub

Splitlog User Guide

Splitlog Features: Follower merging

This document will explain how you can use Splitlog to combine various log files into one.

What is follower merging?

When you have two and more Followers, you can merge them into one and treat them like a single unit. This is especially handy when these followers come from different LogWatch instances and therefore are receiving Messages from different log files. However, nothing prevents you from merging followers on the same LogWatch.

Merging followers are the aggregation of their respective followers, with the following characteristics:

  • Every message that the follower is notified of, the merge will be notified of as well. When multiple followers within a merge are watching the same file, the resulting merge will be notified of these Messages once for each follower.
  • MergingFollower’s getMessages() and write() will only work with the Messages that are, at the moment, accessible through at least one of its merged followers. MergingFollower doesn’t store any message data on its own, but it will track metrics independently.
  • Metrics or consumers registered with the respective followers are never transferred to the merge.
  • MergingFollower is immutable with respect to its followers. Whenever you want to add/remove another follower to/from the merge, a different MergingFollower instance will be created.

Merging followers are a summation of their respective merged followers. Nothing more should be expected of them.

How do I merge followers?

It’s as easy as this:

  Follower follower1 = ...; 
  Follower follower2 = ...;
  MergingFollower merge = follower2.mergeWith(follower1); // the order has no effect

And you can also merge MergingFollowers:

  Follower follower1 = ...; 
  MergingFollower follower2 = ...;
  MergingFollower merge = follower1.mergeWith(follower2);
  MergingFollower follower3 = ...;
  MergingFollower merge2 = merge.mergeWith(follower3);
References
  1. Follower Javadoc.
  2. MergingFollower Javadoc.

——————————————-

Something wrong?

Think you spotted a mistake in this document? A typo? Factual inaccuracy? Make an edit. Think of the legions of grateful users!