Off course, the web log file viewer from OH (frontail) is very nice, but sometimes you need a little more. And sometimes, the commandline is where you are. You might consider using lnav (Logfile NAVigation). I tried several of them, but this one seems to be very powerful.
It can ready the openhab.log file, even if its compressed ! And it is constantly updating, like “tail -f”
Start it in the shell like:
lnav /etc/openhab/log/openhab.log.7.gz
An impression of how it looks, with two patterns marked:
Some usefull hotkeys:
- e / E : jump to next/previous ERROR ( I especially like this one)
- w / W: jump to next/previous WARNING
- d / D : forward / backward 24 hours
- 0 / shift 0 : next / previous day
- ctrl-r : reset all filters and highlights
- i : show a histogram with number of errors per day
- p / shift p : show / stop showing JSON messages in a pretty way
- / : search a string of regular expression
- g / G : go to top or bottom of the file
Some interesting commands (use : to get into command mode) :
- :filter-in <regex-searchstring> : show only lines matching the regex searchstring
- :filter-out <regex-searchstring> : do not show matching lines
- :highlight <regex-searchstring> : mark all matching strings with a color (you can apply serveral on top of each other)
Nice, but the default file (sudo apt install lnav) is a very old one. Download the sources and install that new version using:
tar xvfz lnav-0.11.2.tar.gz
cd lnav-0.11-2
sudo apt install libcurl4-openssl-dev ncurses-dev libpcre2-dev libreadline-dev libsqlite3-dev
make # and wait an hour or so
sudo make install
Note that is possible to create your own format. The Openhab log format is pretty much recognized. I tried to create this format, but did not succeed yet. I should be possible to filter out the block containing text about the module of OH which is not always interesting:
2023-12-19 20:05:04.016 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Uncompressed format
2023-12-19 20:05:04.016 [DEBUG] […] - Compressed format
This would make the output less wide. But let’s save that for later. And a whole lot of other features
I’ll hope you enjoy this tool. If not, be happy with any other tool you like.