Obviously, we can use cat, tail, grep commands with or without unix pipe for normal works. But there are command line tool name lnav to colorize the output. It has built-in log message parser can automatically discover and extract interesting data from plainly formatted log messages. Here is How to Install Log File Navigator lnav on Ubuntu 16.04. lnav is a Command Line Tool with ncurses Text Based User Interface (TUI) to Check the /var/log files. Checking of Nginx, PHP-FPM Logs like works becomes easier.
lnav
has histogram view, filters, live operation, automatic tailing, ordering of lines, syntax highlighting, search, hotkeys etc.
How to Install Log File Navigator lnav (Ubuntu 16.04)
Installing log file navigator lnav on Ubuntu 16.04 is just easy. There is Apt package and corresponding manual page :
---
1 2 | http://manpages.ubuntu.com/manpages/xenial/man1/lnav.1.html https://raw.githubusercontent.com/tstack/lnav/master/src/help.txt |
We simply need to run :
1 | apt install lnav |
and rest will be automatically done. There is another tool named ccze
. ccze
colorizes logs which are sent to standard out, we can use tail
to follow a log file and then prettify. It is not exactly so great. lnav
has lot of features :
1 2 3 4 5 6 | http://tstack.github.io/lnav/ http://lnav.org/features/ http://lnav.readthedocs.io/en/latest/index.html http://lnav.readthedocs.io/en/latest/formats.html http://lnav.readthedocs.io/en/latest/hotkeys.html#hotkeys http://lnav.readthedocs.io/en/latest/commands.html#commands |
Documentation is not easy to find.
How to Install Log File Navigator lnav : Usage
q
quits the program’s interface.
lnav -s
command loads /var/log/syslog
.
lnav /var/log
command loads all of the files in /var/log/dpkg.log
.
To see the output with timestamps perpended we can use unix pipe and process with -t
flag i.e. lnav -t
.
As an example, take we have to check the logs on a server with Nginx, PHP-FPM installed. For simple access.log viewing, we can use :
1 | lnav /var/log/nginx/access.log |
To view the errors, we can use :
1 | lnav /var/log/nginx/error.log.1 |
For complicated matter, like checking log for XML-RPC attack (which usually gives PHP-FPM error), instead of :
1 | awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn |
so much not needed with lnav
:
1 | lnav /var/log/nginx/access.log |
hit /
key, then type 200
. It will show 8 hits
. Type q
hit Enter key, again q
hit Enter key to exit.
But OS X iTerm2 Not Giving Colors Like That of Your Screenshoot Shown?
If you are using OS X iTerm2 with Homebrew, then you may search our website with iTerm2
for configurations. In short, you will do small thing :
[iTerm2] > Preference > Profiles > Colors > Smart cursor colors (checked), adjust minimum contrast to around 50%.
Also, you can try :
[iTerm2] > Preference > Profiles > Window > set Transparency to 0% temporarily.
Tagged With install file to navigator , ubuntu lnav install