All articles

MFCommander · File viewer

Open and search huge log files on macOS

Inspect a 1 GiB log, find a request identifier and move between matches.

A large log is useful only if you can get to the lines you need. MFCommander’s text viewer lets you open the file, search for a phrase and move between matches while keeping the surrounding text in view.

This walkthrough uses a generated 1 GiB local log containing 8,388,608 lines. It starts with a literal search for a request marker, then switches to a regular expression. Substitute a phrase or identifier from the file you are investigating.

Open the log in the viewer

Find the log in a file pane, select it and press F3. Check the file name when the viewer opens. Start with a few visible lines to confirm that you have the intended export and that the text is readable.

Use the status bar for the information reported about the open file. The viewer reads the text needed for the visible region rather than turning the entire log into an editable text document. That does not make a full-file search instantaneous.

A generated 1 GiB log open in MFCommander’s text viewer, with different timestamps, services and messages on successive lines.
Select the local log and open it with F3.

Check the line information

The viewer builds a sparse line index in the background. You can read and scroll before it finishes. This lets you begin with the visible text while line information is still being gathered.

Exact line navigation depends on that index. A jump to a line beyond the indexed region can wait until the index reaches it. If you are waiting for a deep line, allow indexing to progress instead of treating the delay as proof that the line is missing.

The generated log in MFCommander’s viewer with a one-gigabyte size and completed count of 8,388,608 lines.
The sample has finished indexing and reports 8,388,608 lines.

Find a literal phrase

Press Command-F to open the find bar. Leave Literal selected and enter the phrase you want to find. For a known request identifier, searching for the identifier itself is often a useful first pass.

Literal search treats pattern characters as text and ignores ASCII letter case. Read the highlighted match with the lines around it. The same identifier may appear in a request, a retry and a completion message.

The match count is calculated separately. A plus sign after the total means counting is still in progress. Wait for the count to settle before treating it as the final total.

The viewer find bar in Literal mode with a known demo request marker highlighted.
Search for a known phrase in Literal mode and let the match count finish.

Move between matches

Use Next and Previous in the find bar to move between matches. Navigation continues from the last hit and wraps at the ends of the file. After the final match, Next can take you back toward the beginning.

Check the text around each result before deciding whether it belongs to the same event. If you change the phrase, you are starting a new search. Use a narrower identifier when a broad word such as error produces too many unrelated matches.

The viewer showing another known match after using the find bar’s Next control.
Use Next and Previous to inspect each match in context.

Use a pattern when needed

Switch to Regex when you need a pattern. For example, request_id=DEMO-[0-9]{4} describes that prefix followed by four digits. Inspect a result to confirm that the pattern is finding the text you intended.

The current regex implementation searches in 4 MiB windows. A match crossing a window boundary can be missed. A no-match result can also mean that a pattern is invalid, as the find bar’s message indicates. Use Literal for a known phrase and do not treat regex results as an exhaustive audit of the file.

Choose Done to close the find bar when you have finished searching. The viewer stays open so you can keep reading the section you reached.

The find bar in Regex mode with a demo request-identifier pattern and its matching text.
Switch to Regex for a pattern, with the search-window limitation in mind.

A useful search ends with a line you can explain in context. Start with a specific phrase, move through the matches and account for indexing and counting progress. Use a pattern when it helps express the question, while keeping the regex boundary limitation in mind.

Explore the MFCommander file manager