lnav
Analyze and navigate log files
TLDR
View logs of a program, specifying log files, directories or URLs
View logs of a specific remote host (SSH passwordless login required)
Validate the format of log files against the configuration and report any errors
SYNOPSIS
lnav [options] [logfile1 logfile2 ...]
PARAMETERS
-a
Load all recently accessed files.
-c
Load the configuration file.
-d
Use the given SQLite database file to persist data. (Defaults to ~/.lnav/lnav.db)
-f
Follow any new log files added.
-i
Rebuild the index database from scratch.
-l
List available log formats.
-n
Do not load the previous history.
-r
Load files in reverse chronological order.
-t
Prepend timestamps to the log messages.
-V
Show version information.
-x
Evaluate an expression after the logs have loaded.
-w
Add a global filter.
DESCRIPTION
lnav is a powerful, curses-based log file viewer that intelligently analyzes and formats log messages from various sources.
It automatically detects log formats like syslog, common web server logs, and glog, enabling users to quickly browse, filter, and correlate events across multiple files. lnav's key features include timeline views, automatic log level detection, SQL queries against log data, and the ability to execute Python scripts for custom analysis. It is invaluable for debugging applications, monitoring system performance, and analyzing security logs efficiently.
lnav focuses on providing an intuitive and interactive experience, leveraging color coding, search capabilities, and powerful filtering to extract valuable insights from voluminous log data. It aims to be more than just a log viewer; it's a complete log analysis environment.
CAVEATS
lnav's performance can degrade when dealing with extremely large log files, especially if they are not well-structured.
Custom log format parsing requires familiarity with lnav's configuration language, which can have a learning curve.
KEYBINDINGS
lnav uses a variety of keybindings for navigation and filtering. Some important keys include: q to quit, / to search, n and N to navigate search results, p to go to previous file, and P to go to next file.
LOG FORMAT DEFINITION
lnav allows you to define your own log formats using XML or JSON. This allows lnav to understand and parse custom log formats not automatically detected. This is extremely powerful for analyzing logs from proprietary applications.
SQL SUPPORT
lnav lets you query log data using SQL. Each log message is parsed into columns that can be used in SQL queries. This allows complex filtering and aggregations.
HISTORY
lnav was created by Tim Raffenberg with the primary goal of improving the experience of navigating and analyzing log files.
Its development focused on automatic format detection, powerful filtering, and correlation to streamline the debugging and troubleshooting process, which was originally released in 2011. Over the years, lnav has gained popularity among developers and system administrators for its advanced features and user-friendly interface.