Logs from three machines, one timeline

Merging by file only puts web-01.log before web-02.log - two separate halves, not one story. What you usually need is every line in the order the events actually happened, whoever logged them.

Download free trialBuy TextMerger

How to merge log files by timestamp

  1. Open TextMerger and click New Task.
  2. Add the log files, or Add Folder... on a folder of rotations.
  3. Tick Sort lines by timestamp and set the Time format if your logs use a format other than the default.
  4. Optionally tick Add source file name column so each line still says which host it came from.
  5. Click Merge - the output is the combined entries in chronological order.

TextMerger after merging two log files in timestamp order, with the result verified

How the timestamp sort works

TextMerger with Sort lines by timestamp and a time format set, merging two log files

The result

Two logs covering the same period come out as one timeline - every entry in the order it happened, whoever logged it. The preview shows the merged file before it is written:

The merged log file in the merge preview, interleaved in timestamp order

Cleaning up as you go

Once the logs are in one timeline, Skip empty lines and Remove duplicate lines tidy the result while it is written. See removing duplicate lines while merging. Sending the result somewhere? Write the output as .gz or .zip and it is compressed as it is written.

What it does not do

It does not parse or reformat log entries. If your format is unusual, set the time format explicitly. Note that sorting by time reads the whole set of lines into memory, so for extremely large logs merge them in batches.

Related tools

Opening a very large merged log instead of merging it: BigTextFileViewer. Splitting a huge log again: BigTextFileSplitter. Full reference: merging text files. Related use case: a month of logs.