lnav

tstackBSD-2-Clause活跃维护

终端里的日志文件浏览器,能自动识别日志格式、高亮显示并按时间合并多个文件,比 less 和 tail 更适合排查线上问题。

Log file navigator

v0.14.1发布于 2026-09-05 04:26 UTC10,786star416fork同步于 2026-11-10 05:29 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
brew install lnav
硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v0.14.1
  1. v0.15.0-beta1pre-release2026-09-28 · 2026-09-28 16:47 UTC
    查看更新说明

    lnav v0.15.0

    Features:

    • Added the :filter-context command to show lines surrounding filter matches, similar to grep's -C option. The command accepts one or two arguments for the number of messages to show before and after each match. In the LOG view, context is counted in whole messages (including continuation lines). The z/Z keys can also be used to increase/decrease the context by one in the LOG, TEXT, and TIMELINE views. Context lines are styled using the new context-line theme style.
    • Added a built-in metrics_log format that recognizes CSV files whose first column header is Time/Timestamp/ts/ Date... and whose subsequent rows begin with a parseable timestamp. Each row is rendered with a timestamp and a <column>=<value> pair for each numeric column. Rows from multiple files that have the same timestamp are merged into a single line. Values are right-aligned and decorated with reverse-video bars proportional to each column's observed min/max range. When the row is focused, an overlay below it labels each column with the source file stem. Exports from Excel, PowerShell, and Grafana should be handled as-is.
    • Added the all_metrics SQL virtual table, a long-format view across every open metrics file. The metric column contains the name of the metric and value contains its value.
    • The TIMELINE view now supports overlaying metric sparklines at the top of the view. The following commands can be used to manage this:
      • :timeline-metric [<source>.]<metric> picks a column from any loaded metrics file
      • :timeline-metric-sql <label> <query> takes an arbitrary SELECT log_time, value FROM ... that can target any table, including search-table columns.
      • :clear-timeline-metric <label> removes metrics. Up to four metrics can be added.
    • Added support for "tabular" formats (e.g. CSV, TSV). The format definition for this type of file sets file-type to tabular and then defines the known columns. When opening a file of this type, the separator will be automatically detected and the header compared against the columns defined in the tabular formats. If a good match is found, it will be used as the format for the file. Quoted cells that span multiple physical lines (an embedded LF inside "...") are stitched back into a single log message, so an Excel-exported CSV with a multi-line free-text column shows one logline per row and SQL/search operates on the merged cell value.
    • Added a log format for the fsck_apfs and fsck_hfs tools on macOS, covering both the started/completed lifecycle lines and legacy run entries. This replaces the previous fsck_hfs_log format, which only matched the start lines. The new format exposes device, tool, and action fields, groups messages by device in the TIMELINE view, and highlights error: lines and FILESYSTEM CLEAN status messages.
    • Added a log format for the Asterisk PBX framework. The call ID (e.g. C-00000001) is used as the operation ID so the messages for a call are grouped in the TIMELINE view.
    • Log format value definitions now accept a unit object with suffix and divisor properties. suffix specifies how numeric fields are humanized. divisor normalizes the raw value to the base unit implied by suffix — e.g. a field storing milliseconds with "suffix": "s" declares "divisor": 1000.
    • The details overlay now shows per-column statistics for the focused message. Numeric columns get a min..max of N range summary on the value line, plus a p50/p90/p99 percentile sub-line for columns with enough samples to characterize the distribution shape. Identifier and metrics-text columns get an estimated distinct-value count (~K distinct of N). Distinct counts are computed from a HyperLogLog sketch (~4 KB per text col
  2. v0.14.1最新正式版2026-09-05 · 2026-09-05 04:26 UTC

    lnav v0.14.1

    Features:

    • Added the :reload-view command, bound to F5/⌘-R, that re-runs the operation that populated the current view. In the DB view, this re-executes the last SQL query; in the TIMELINE view, it rebuilds the index. Views that don't have a meaningful reload report an error.
    • The DB view now shows a status bar above the bottom status bar with the SQL query that populated the view, the relative time when it was run, and how long it took. A reload icon on the left side of the bar can be clicked to re-run the query. For queries that read from log-backed tables, the status bar also calls out whether the results are "on current log data" or "on old log data" relative to what lnav is currently indexing. The same information is exposed via the new lnav_views.view_details column.
    • For terminals that support the Kitty Keyboard protocol, the following hotkeys are now supported in the prompt:
      • ⌘-C to copy the current selection to the clipboard.
      • ⌘-A to select all text.
      • ⌘-X to cut the current selection to the clipboard.
      • ⌘-Z to undo the last change.
    • The multi-line prompt can now be resized with the keyboard: ALT-= grows the prompt by one line and ALT-- shrinks it by one line. This complements the existing click-and-drag resize on the prompt's status bar.
    • Additional readline-style key bindings in the prompt (issue #1676):
      • ALT-f / ALT-b move forward/backward by word.
      • ALT-d cuts to the end of the next word.
      • ALT-BACKSPACE is an alias for CTRL-W.
      • ALT-l / ALT-u lower- or upper-case the next word.
      • ALT-c capitalizes the next word.
      • CTRL-h and CTRL-d are aliases for BACKSPACE and DELETE.
      • CTRL-t transposes the two characters before the cursor.
    • In the log message details (opened by pressing p), a File: row has been added that lists the file and line number the log message is from. Also, for JSON logs, you can focus on the JSON fields: row and press c to copy the raw log message to the clipboard.
    • The measure_with_units collator now recognizes (KiB, MiB, ...).
    • Added disfavors to external-editor configuration to express file names that the editor is not interested in handling.
    • The lnav_views.view_details column is now populated for every time-based view (log, histogram, spectro, timeline, db) with a JSON zoom-level field reflecting the current :zoom-to setting.
    • The :zoom-to command (and the z/Z hotkeys) now affects only the currently focused view; previously, zooming in either the histogram or the spectrogram view would change both views' zoom level in lockstep. Each view (log, histogram, spectro, timeline, db) now has its own independent zoom level.
    • The :zoom-to command now accepts + and - as shortcuts to step in or out by one level from the current view's zoom (the same behavior as the z/Z hotkeys).
    • SQL statements can now use $zoom_level to refer to the current zoom level in the DB view. Pressing z/Z in the DB view will now rerun the last query with the new zoom value. The stats.hist PRQL function now uses $zoom_level as the default value for the slice parameter.
    • A stats.timeseries PRQL function has been added to make it easier to perform an aggregation over buckets of time.

    Breaking changes:

    • Mouse mode is disabled by default again since there has been some grumbling and it needs some refinement.
    • The humanize_file_size() SQLite function now uses 1,000 for the base instead of 1,024.

    Bug Fixes:

    • A PRQL query can now start with let in interactive mode.
    • Fix a bug in file loading that could cause a short read and crash in some situations.
    • Fix a lockup when viewing a file that contained log messages and lots of binary data.
    • Update Regex101 import functi
  3. v0.14.1-rc1pre-release2026-05-10 · 2026-05-10 17:52 UTC
    查看更新说明

    lnav v0.14.1

    Features:

    • Added the :reload-view command, bound to F5/⌘-R, that re-runs the operation that populated the current view. In the DB view, this re-executes the last SQL query; in the TIMELINE view, it rebuilds the index. Views that don't have a meaningful reload report an error.
    • The DB view now shows a status bar above the bottom status bar with the SQL query that populated the view, the relative time when it was run, and how long it took. A reload icon on the left side of the bar can be clicked to re-run the query. For queries that read from log-backed tables, the status bar also calls out whether the results are "on current log data" or "on old log data" relative to what lnav is currently indexing. The same information is exposed via the new lnav_views.view_details column.
    • For terminals that support the Kitty Keyboard protocol, the following hotkeys are now supported in the prompt:
      • ⌘-C to copy the current selection to the clipboard.
      • ⌘-A to select all text.
      • ⌘-X to cut the current selection to the clipboard.
      • ⌘-Z to undo the last change.
    • The multi-line prompt can now be resized with the keyboard: ALT-= grows the prompt by one line and ALT-- shrinks it by one line. This complements the existing click-and-drag resize on the prompt's status bar.
    • Additional readline-style key bindings in the prompt (issue #1676):
      • ALT-f / ALT-b move forward/backward by word.
      • ALT-d cuts to the end of the next word.
      • ALT-BACKSPACE is an alias for CTRL-W.
      • ALT-l / ALT-u lower- or upper-case the next word.
      • ALT-c capitalizes the next word.
      • CTRL-h and CTRL-d are aliases for BACKSPACE and DELETE.
      • CTRL-t transposes the two characters before the cursor.
    • In the log message details (opened by pressing p), a File: row has been added that lists the file and line number the log message is from. Also, for JSON logs, you can focus on the JSON fields: row and press c to copy the raw log message to the clipboard.
    • The measure_with_units collator now recognizes (KiB, MiB, ...).
    • Added disfavors to external-editor configuration to express file names that the editor is not interested in handling.
    • The lnav_views.view_details column is now populated for every time-based view (log, histogram, spectro, timeline, db) with a JSON zoom-level field reflecting the current :zoom-to setting.
    • The :zoom-to command (and the z/Z hotkeys) now affects only the currently focused view; previously, zooming in either the histogram or the spectrogram view would change both views' zoom level in lockstep. Each view (log, histogram, spectro, timeline, db) now has its own independent zoom level.
    • The :zoom-to command now accepts + and - as shortcuts to step in or out by one level from the current view's zoom (the same behavior as the z/Z hotkeys).
    • SQL statements can now use $zoom_level to refer to the current zoom level in the DB view. Pressing z/Z in the DB view will now rerun the last query with the new zoom value. The stats.hist PRQL function now uses $zoom_level as the default value for the slice parameter.
    • A stats.timeseries PRQL function has been added to make it easier to perform an aggregation over buckets of time.

    Breaking changes:

    • The humanize_file_size() SQLite function now uses 1,000 for the base instead of 1,024.

    Bug Fixes:

    • A PRQL query can now start with let in interactive mode.
    • Fix a bug in file loading that could cause a short read and crash in some situations.
    • Fix a lockup when viewing a file that contained log messages and lots of binary data.
    • Update Regex101 import functionality to handle a change in their API response.
    • More hardening for some diabolical inputs:
      • Unsuppor
  4. v0.14.02026-04-12 · 2026-04-12 19:48 UTC
    查看更新说明

    lnav v0.14.0

    Features:

    • The Filter configuration panel in the TUI now supports editing the minimum log level and minimum/maximum times for the current view. Previously, only the :set-min-log-level, :hide-lines-before, and :hide-lines-after commands could be used to set the values. Pressing l will create/set the log level. Pressing m will create/set the minimum time and pressing Shift + M will create/set the maximum time. Live preview has also been added to show which lines will be filtered out when the min/max is applied.
    • The -S/--since and -U/--until flags have been added to limit how much of a log file is indexed. Supported values are relative (e.g. "yesterday", "30 min ago") or absolute local times ("2020-01-01"). The values on the main command-line set the defaults for all values that are opened. The :open command supports the same options to change the values from the default for a particular file. Files with content that lie completely outside of the cutoff will be closed to reduce resource usage.
    • Broadened support for viewing files on remote hosts. The "tailer" program that is transferred to the remote host to monitor files and perform other tasks has been translated to Python3. If the remote host does not have Python, lnav will fall back to the APE binary.
    • Highlights can now be applied to a particular field instead of the whole line. For log formats, a value entry can now have a highlights object that contains definitions for the pattern to match and the style to apply. For interactive use, the :highlight-field command was added.
    • The "Files" panel now shows a progress bar for each file as it is being indexed and finishes with a check-mark if indexing was successful, a warning sign if the file has some notes, or an error mark if something else happened.
    • The :write-jsonlines-to command now supports the LOG view. When lines are marked in the LOG view, the command will write each marked log message as a JSON object with the standard log fields (log_path, log_time, log_level, log_opid, log_line_link) along with any format-specific parsed values, comments, and tags. The --all flag can be used to write all visible log lines instead of only marked lines.
    • Added a log format for MongoDB's structured JSON log format (4.4+).
    • Added a log format for the Robot Framework's debug log file format.
    • Added "timestamp" as a value kind for log format definitions. Fields with this kind will be parsed and displayed in the local timezone, and SQL queries will return them in a normalized format.
    • Added the :toggle-sticky-header command to pin a line to the top of the view as a sticky header. Sticky headers remain visible as you scroll past them, making it easy to keep context lines in view. The :clear-all-sticky-headers command removes all sticky headers in the current view. A hidden log_sticky_mark column is available in log tables to get/set the sticky state via SQL. Sticky headers and user bookmarks are saved and restored across sessions for both log and text views. The command is bound to CTRL+S by default.
    • In pager mode (activated by the -q flag), the input will always be written to the terminal if it is smaller than the height. Previously, if the input took awhile to generate, nothing would be written. Also, when the input is larger than the terminal height, any marked lines will be written to the terminal.
    • Introducing "Log-Oriented Debugging", a collection of features to streamline mapping log messages back to the source code that generated them. For example, given the log message "Hello, Steve!" and the source directory containing the log statement. lnav can find the line of code that generated the message, such as `logging.info("
  5. v0.14.0-rc2pre-release2026-04-12 · 2026-04-12 18:22 UTC
    查看更新说明

    lnav v0.14.0

    Features:

    • The Filter configuration panel in the TUI now supports editing the minimum log level and minimum/maximum times for the current view. Previously, only the :set-min-log-level, :hide-lines-before, and :hide-lines-after commands could be used to set the values. Pressing l will create/set the log level. Pressing m will create/set the minimum time and pressing Shift + M will create/set the maximum time. Live preview has also been added to show which lines will be filtered out when the min/max is applied.
    • The -S/--since and -U/--until flags have been added to limit how much of a log file is indexed. Supported values are relative (e.g. "yesterday", "30 min ago") or absolute local times ("2020-01-01"). The values on the main command-line set the defaults for all values that are opened. The :open command supports the same options to change the values from the default for a particular file. Files with content that lie completely outside of the cutoff will be closed to reduce resource usage.
    • Broadened support for viewing files on remote hosts. The "tailer" program that is transferred to the remote host to monitor files and perform other tasks has been translated to Python3. If the remote host does not have Python, lnav will fall back to the APE binary.
    • Highlights can now be applied to a particular field instead of the whole line. For log formats, a value entry can now have a highlights object that contains definitions for the pattern to match and the style to apply. For interactive use, the :highlight-field command was added.
    • The "Files" panel now shows a progress bar for each file as it is being indexed and finishes with a check-mark if indexing was successful, a warning sign if the file has some notes, or an error mark if something else happened.
    • The :write-jsonlines-to command now supports the LOG view. When lines are marked in the LOG view, the command will write each marked log message as a JSON object with the standard log fields (log_path, log_time, log_level, log_opid, log_line_link) along with any format-specific parsed values, comments, and tags. The --all flag can be used to write all visible log lines instead of only marked lines.
    • Added a log format for MongoDB's structured JSON log format (4.4+).
    • Added a log format for the Robot Framework's debug log file format.
    • Added "timestamp" as a value kind for log format definitions. Fields with this kind will be parsed and displayed in the local timezone, and SQL queries will return them in a normalized format.
    • Added the :toggle-sticky-header command to pin a line to the top of the view as a sticky header. Sticky headers remain visible as you scroll past them, making it easy to keep context lines in view. The :clear-all-sticky-headers command removes all sticky headers in the current view. A hidden log_sticky_mark column is available in log tables to get/set the sticky state via SQL. Sticky headers and user bookmarks are saved and restored across sessions for both log and text views. The command is bound to CTRL+S by default.
    • In pager mode (activated by the -q flag), the input will always be written to the terminal if it is smaller than the height. Previously, if the input took awhile to generate, nothing would be written. Also, when the input is larger than the terminal height, any marked lines will be written to the terminal.
    • Introducing "Log-Oriented Debugging", a collection of features to streamline mapping log messages back to the source code that generated them. For example, given the log message "Hello, Steve!" and the source directory containing the log statement. lnav can find the line of code that generated the message, such as `logging.info("

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Build Docs Coverage Status lnav Gurubase

    This is the source repository for lnav, visit https://lnav.org for a high level overview.

    LNAV -- The Logfile Navigator

    The Logfile Navigator is a log file viewer for the terminal. Given a set of files/directories, lnav will:

    • decompress as needed;
    • detect their format;
    • merge the files by time into a single view;
    • tail the files, follow renames, find new files in directories;
    • build an index of errors and warnings;
    • pretty-print JSON-lines.

    Then, in the lnav TUI, you can:

    Screenshot

    The following screenshot shows a mix of syslog and web access log files. Failed requests are shown in red. Identifiers, like IP address and PIDs are semantically highlighted.

    Screenshot

    Why not just use tail/grep/less?

    The standard Unix utilities are great for processing raw text lines, however, they do not understand log messages. Tail can watch multiple files at a time, but it won't display messages in order by time and you can't scroll backwards. Grep will only find matching lines, but won't return a full multi-line log message. Less can only display a single file at a time. Also, none of these basic tools handle compressed files.

    Try online before installing

    You can SSH into a demo node to play with lnav before installing.

    The "playground" account starts lnav with a couple of log files as an example:

    $ ssh [email protected]

    The "tutorial 1" account is an interactive tutorial that can teach you the basics of operation:

    $ ssh [email protected]

    Installation

    Download a statically-linked binary for Linux/MacOS/Windows from the release page

    Brew on MacOS

    $ brew install lnav
    

    FreeBSD

    $ pkg install lnav
    

    Usage

    Simply point lnav at the files or directories you want to monitor, it will figure out the rest:

    $ lnav /path/to/file1 /path/to/dir ...
    

    The lnav TUI will pop up right away and begin indexing the files. Progress is displayed in the "Files" panel at the bottom. Once the indexing has finished, the LOG view will display the log messages that were recognized1. You can then use the usual hotkeys to move around the view (arrow keys or j/k/h/l to move down/up/left/right).

    See the Usage section of the online documentation for more information.

    Usage with systemd-journald

    On systems running systemd-journald, you can use lnav as the pager:

    $ journalctl | lnav
    

    or in follow mode:

    $ journalctl -f | lnav
    

    Since journalctl's default output format omits the year, if you are viewing logs which span multiple years you will need to change the output format to include the year, otherwise lnav gets confused:

    $ journalctl -o short-iso | lnav
    

    It is also possible to use journalctl's json output format and lnav will make use of additional fields such as PRIORITY and _SYSTEMD_UNIT:

    $ journalctl -o json | lnav
    

    In case some MESSAGE fields contain special characters such as ANSI color codes which are considered as unprintable by journalctl, specifying journalctl's -a option might be preferable in order to output those messages still in a non-binary representation:

    $ journalctl -a -o json | lnav
    

    If using systemd v236 or newer, the output fields can be limited to the ones actually recognized by lnav for increased efficiency:

    $ journalctl -o json --output-fields=MESSAGE,PRIORITY,_PID,SYSLOG_IDENTIFIER,_SYSTEMD_UNIT | lnav
    

    If your system has been running for a long time, for increased efficiency you may want to limit the number of log lines fed into lnav, e.g. via journalctl's -n or --since=... options.

    In case of a persistent journal, you may want to limit the number of log lines fed into lnav via journalctl's -b option.

    Support

    Please file issues on this repository or use the discussions section. The following alternatives are also available:

    Links

    Contributing

    Building From Source

    Prerequisites

    The following software packages are required to build lnav:

    • gcc/clang - A C++14-compatible compiler.
    • libpcre2 - The Perl Compatible Regular Expression v2 (PCRE2) library.
    • sqlite - The SQLite database engine. Version 3.9.0 or higher is required.
    • zlib - The zlib compression library.
    • bz2 - The bzip2 compression library.
    • libcurl - The cURL library for downloading files from URLs. Version 7.23.0 or higher is required.
    • libarchive - The libarchive library for opening archive files, like zip/tgz.
    • libunistring - The libunistring library for dealing with unicode.
    • wireshark - The 'tshark' program is used to interpret pcap files.
    • cargo/rust - The Rust language is used to build the PRQL compiler.
    Build

    Lnav follows the usual GNU style for configuring and installing software:

    Run ./autogen.sh if compiling from a cloned repository.

    $ ./configure
    $ make
    $ sudo make install
    

    See Also

    Angle-grinder is a tool to slice and dice log files on the command-line. If you're familiar with the SumoLogic query language, you might find this tool more comfortable to work with.

    Code Signing Policy

    Free code signing provided by SignPath.io, certificate by SignPath Foundation.

    This program will not transfer any information to other networked systems unless specifically requested by the user or the person installing or operating it.

    Acknowledgements

    Many thanks to:

    • GitHub Sponsors
    • Anthropic for including lnav in the Claude for Open Source Program

    Footnotes

    1. Files that do not contain log messages can be seen in the TEXT view (reachable by pressing t). ↩