If you have a problem with your computer, you may have to go through log files, or as a software engineer, you may be looking for clues about a bug in a debug or error log. It can be done in any text editor, but there may be a better way thanks to lnav Log Files Navigator that allows checking those files more easily and efficiently in a Mac OS or Linux terminal.
The following log files are supported by default even if they are compressed with gzip or bzip2:
- Common Web Access Log format
- CUPS page_log
- VMware ESXi/vCenter Logs
- “Generic” – Any message that starts with a timestamp
lnav is open-source software released under a BSD-2 clause in Github. It’s not new at all as some commits were made in January 2010, but it’s new to me, and hopefully to some of you as well.
There are various ways to install it, but the easiest way in Ubuntu is to install it as a snap.
sudo snap install lnav
Launching lnav with no other parameters will open /var/log/syslog automatically.
If you’re familiar with Vi/Vim, using lnav should be fairly easy as many of the commands are the same. For example, we can search with “/” to filter messages with a specific string.
You can select the next/previous occurrence of the string with n/N. Tabulation is also supported so you don’t need to copy/paste or type longer strings.
If you want to master the program and make the most of it, you’ll need to read the documentation for command line parameters and shortcuts, as there are so many options.
Some of the cool features of the program include Single Log View showing all logs in a single window based on message timestamps, filtering content with regular expressions, a Timeline View showing when most errors and warnings occurred, Pretty-Print View to reformat structured data such as XML or JSON, and more.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
|Support CNX Software - Donate via PayPal or become a Patron on Patreon|