From 03a8ae9bc5906c5b49ab5c8c7e98af2176b65050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E5=BC=80=E7=AE=B1?= Date: Mon, 28 Nov 2022 11:50:53 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][tech]:?= =?UTF-8?q?=2020221127.0=20=E2=AD=90=EF=B8=8F=20lnav=20Advanced=20Log=20Fi?= =?UTF-8?q?le=20Viewer=20for=20Linux=20Desktops=20and=20Servers.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... File Viewer for Linux Desktops and Servers.md | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 sources/tech/20221127.0 ⭐️ lnav Advanced Log File Viewer for Linux Desktops and Servers.md diff --git a/sources/tech/20221127.0 ⭐️ lnav Advanced Log File Viewer for Linux Desktops and Servers.md b/sources/tech/20221127.0 ⭐️ lnav Advanced Log File Viewer for Linux Desktops and Servers.md new file mode 100644 index 0000000000..ab3e8307ac --- /dev/null +++ b/sources/tech/20221127.0 ⭐️ lnav Advanced Log File Viewer for Linux Desktops and Servers.md @@ -0,0 +1,127 @@ +[#]: subject: "lnav: Advanced Log File Viewer for Linux Desktops and Servers" +[#]: via: "https://www.debugpoint.com/advanced-log-file-viewer-lnav-ubuntu-linux/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +lnav: Advanced Log File Viewer for Linux Desktops and Servers +====== + +**If you want to debug or troubleshoot any issues, you need an advanced log file viewer like lnav – which works wonders in the terminal for any Linux system.** + +### lnav: Log file viewer + +lnav can unzip all the compressed log files on the fly and merge them together for a nice display. The display is parsed and formatted based on the types of errors/warnings – this helps to quickly glance through the thousands of logs, especially in servers. + +While analysing the logs, timestamps are very important. So lnav merges multiple logs based on timestamps, which is very helpful for tracking down system issues. + +Most of the important log file format detection is built-in; see below: + +- Common Web Access Log format +- CUPS page_log +- Syslog +- Glog +- VMware ESXi/vCenter Logs +- dpkg.log +- uwsgi +- “Generic” – Any message that starts with a timestamp +- Strace +- sudo +- GZIP, BZIP + +That is not all; lnav is also capable of the below features, making it an important app for Linux systems. + +- Filter messages based on regular expression +- A timeline view of errors +- Pretty-Print view- helps to reformat +- Query Log using SQL +- A log is updated in real-time while being searched. +- Syntax highlight via regular expression (say you want to find out an IP address in the entire log) +- Tab completion of any word from the log which is displayed !! + +![lnav-running-in-ubutu][1] + +To view the screenshots of the above features and learn more, visit [this page.][2] + +### How to Install + +This program is available in official Ubuntu, Debian repo. Install it using the following command. + +``` +sudo apt install lnav +``` + +And for Fedora, RHEL users, use the below command: + +``` +sudo dnf install lnav +``` + +Also the developers provides an offline standalone executable which you don’t need to install. You can download the zip from the [GitHub release page][3] and execute as: + +``` +./lnav +``` + +**Note**: It’s also available for macOS which you can find in the above GitHub page. + +### lnav: How to use (Basics) + +The simple command syntax is: + +``` +lnav [options] [logfile1 logfile2 …] +``` + +If you run just lnav from the command, it shows all the logs from your system (/var/log/messages and /var/log/syslog) + +``` +lnav +``` + +To view any specific log file, provide it via the command line: + +``` +lnav /var/log/syslog +``` + +Add timestamp in your log output using -t parameter + +``` +lnav -t /var/log/syslog +``` + +Here are some of the key switches of lnav + +``` +-d file Write debug messages to the given file.-a Load all of the most recent log file types.-r Load older rotated log files as well.-t Prepend timestamps to the lines of data being read inon the standard input.-w file Write the contents of the standard input to this file.-c cmd Execute a command after the files have been loaded.-f path Execute the commands in the given file.-n Run without the curses UI. (headless mode) +``` + +![lnav running in Ubuntu 22.04][4] + +For further reading and exploration, visit the [official documentation][5]. + +[Next:How to Make LibreOffice Look Like Microsoft Office][6] + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/advanced-log-file-viewer-lnav-ubuntu-linux/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/wp-content/uploads/2016/11/lnav-Running-in-Ubutu.png +[2]: http://lnav.org/features/ +[3]: https://github.com/tstack/lnav/releases/ +[4]: https://www.debugpoint.com/wp-content/uploads/2016/11/lnav-running-in-Ubuntu-22.04.jpg +[5]: https://docs.lnav.org/en/latest/intro.html +[6]: https://www.debugpoint.com/libreoffice-like-microsoft-office/