mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-01 21:50:13 +08:00
128 lines
4.2 KiB
Markdown
128 lines
4.2 KiB
Markdown
[#]: 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/
|