novair Back to Novair Logs
Novair LogsLog files

How to merge log files by timestamp

An incident rarely fits in one log. To see what happened, you put the API, the database and the web server on one timeline. The hard part is not sorting: it is that each log writes time its own way.

Three logs, three ways to write time

The same minute of our sample incident, in three logs. The API writes UTC (Z), the database writes local time with no zone, nginx writes local time with its offset (+0100).

{"time":"2026-11-09T13:04:57.473Z","level":"error","logger":"PaymentClient","msg":"Payment authorization failed: upstream timeout after 3000 ms","provider":"stripe","attempt":1,"order_id":"ord_CC46F","client_ip":"10.20.6.31","customer":{"email":"lea.martin@shop.test"},"trace_id":"05370bb73c6ceb46fd166f168d1fb61d"}
{"time":"2026-11-09T13:04:57.478Z","level":"warn","logger":"CheckoutService","msg":"Retrying order in 500 ms","order_id":"ord_CC46F","order_retry":1,"trace_id":"05370bb73c6ceb46fd166f168d1fb61d"}
2026-11-09 14:05:44.500 [4127] WARNING:  process 4127 still waiting for ShareLock on transaction 880578 after 1000.112 ms
2026-11-09 14:05:46.154 [4124] ERROR:  canceling statement due to statement timeout
10.20.6.66 - - [09/Nov/2026:14:05:44 +0100] "POST /api/checkout HTTP/1.1" 201 412 "https://shop.test/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15"
10.20.8.80 - - [09/Nov/2026:14:05:45 +0100] "GET /api/cart HTTP/1.1" 504 160 "https://shop.test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36"

Read as text, 13:04:57 comes before 14:05:44. In real time, the payment error at 13:04:57 UTC is one minute before the database timeout and the 504 at 14:05 local time (13:05 UTC).

With sort on the command line

sort -m merges files that are already sorted, and it works when every file starts with the same timestamp format in the same zone. With three formats it sorts the text, not the time: you first have to rewrite every timestamp to one zone and one format, and multi-line entries (stack traces) are cut apart.

Time zones and clock drift

  • Give every log its zone: UTC for the API, the server's zone for a log without one.
  • Correct the clock of a machine that was ahead or behind, to the millisecond if needed.
  • Keep the order inside each log: two entries with the same time stay in the order they were written.
  • Keep stack traces with their entry.

In VS Code with Novair Logs Pro

Merge up to 8 logs into one view by time, with a time zone and a clock adjustment for each log; the order inside each log never changes, and the merged view keeps following live. Select the logs in the Explorer and choose Novair Logs: Merge logs by time….

Above the rows, the error timeline shows the first error, the peak and the last error of all the logs; drag over it to filter a time range. Try it first on the three sample logs, with no key: Novair Logs: Open the sample logs (Pro preview).

What can go wrong

  • A log with no time at all (build output, print lines): “No time found in the first 200 lines of build-output.log. It cannot be merged.”
  • Too many files at once: “You can merge up to 8 logs at a time.”
  • A clock adjustment typed in the wrong form: “Write it as hours:minutes:seconds, up to 23:59:59.999, for example -00:00:02.500 (minus for a clock that was ahead).”

Frequently asked questions

Is merging free?

Merging is a Pro feature (EUR 24.17 + VAT where applicable, one-time purchase). The free version opens, follows and filters each log; the sample logs unlock merging with no key.

Does the merged view keep following?

Yes. New lines of each log join the merged view as they are written, at their place in time.

Merge your own logs on one timeline

Novair Logs for VS Code opens large logs as a stream, follows them live without flicker and filters them by level, regular expression or JSON field, on your machine. Free, no account; Pro merges several logs by time and writes an anonymized copy.