General programs are deployed in a Linux environment, and when viewing logs, typically less is used to meet most of the requirements.
Enumerating and documenting the most common scenarios, the code takes the Tomcat log file Catalna.out as an example.
View files directly
Less Catalina.out
After viewing the file, if the file is too large, hit the following command to scroll the file:
J Next line K prev line f Scroll down one screen b scroll up one screen g navigate to document head G Navigate to the end of document
Exit View File
Q Exit less mode
With line number view file
Log files generally have tens of thousands of lines, with line number display will be more convenient
less-n catalina.out
Find content
When looking for keyword content, it's common to look down and look up. As found in the log, because the log is generally appended, from the bottom up to find more common.
/keyword down find n matches next match text n up match next match text? Keyword up n matches next match text n matches next match text down
View document changes in real time (real-time scrolling documents)
After entering less mode, type F, which scrolls the document in real time
F Real-time scrolling documents
Ctrl + C exits live scrolling mode similar effect:tail -F catalina.out
"Linux" To view log files with less