tipsandtricks:howtoreadlogs
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tipsandtricks:howtoreadlogs [2021/11/16 08:51] – patrik | tipsandtricks:howtoreadlogs [2023/09/29 07:01] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== How to read logs in *nix cli ====== | ====== How to read logs in *nix cli ====== | ||
| - | This is mostly based on the bash terminal but should be more application (less, tail and so on) than the specific terminal. | + | // |
| + | by Patrik Hermansson | ||
| + | // | ||
| + | |||
| + | This is mostly based on the bash terminal but should be more application (less, tail and so on) than the specific terminal.\\ | ||
| + | This is also how i use the application listed below to read logs and to troubleshoot. | ||
| * [[howtoreadlogs# | * [[howtoreadlogs# | ||
| Line 12: | Line 17: | ||
| ===== The commands ===== | ===== The commands ===== | ||
| === Less === | === Less === | ||
| - | [[https:// | + | [[https:// |
| - | This | + | Less is the main tool I am using when reading logs. I find the search function good and its quick to open and search in.\\ |
| - | is | + | == Searching in the file == |
| + | /[search pattern] = search from current position for next occurrence in log \\ | ||
| + | ?[search pattern] = search from current position for previous occurrence in log \\ | ||
| - | the | + | == How to navigate logs == |
| - | + | g = go to top of the log (top of file) \\ | |
| - | less | + | Can also be used to go to a specific row '' |
| - | + | G = go to the end of log (bottom of file)\\ | |
| - | application | + | n = go to next hit down in the search pattern \\ |
| - | + | N = go to previous hit up in the search pattern \\ | |
| - | and | + | q = quit less \\ |
| - | + | ||
| - | good | + | |
| - | + | ||
| - | things | + | |
| - | + | ||
| - | to | + | |
| - | + | ||
| - | know | + | |
| - | + | ||
| - | regarding | + | |
| - | + | ||
| - | that | + | |
| === Tail === | === Tail === | ||
| - | [[https:// | + | [[https:// |
| - | is | + | Tail is a usefull application for looking att appending logs. Or just the last 10 rows in the logfile. |
| - | + | ||
| - | another | + | |
| - | + | ||
| - | good | + | |
| + | I use it for: | ||
| + | - See the end of the log-file. | ||
| + | - Let tail print new rows added to the logfile. | ||
| - | application | + | tail {logfile} |
| + | This will print out the last 10 rows to standard out = the screen. \\ | ||
| + | You can choose the number of files to be printed to screen. Use the -n flag. | ||
| + | tail -n 20 {logfile} | ||
| + | This will print out the last 20 rows of the logfile. | ||
| - | for | + | tail -f {logfile} |
| + | This will print out the last 10 rows and continue to print out rows when they are added to the logfile. | ||
| - | log | + | You can also combine the two if you want to see more rows from the logfile at the start. |
| + | tail -f -n 20 {logfile} | ||
| - | and | ||
| - | troubleshooting | ||
tipsandtricks/howtoreadlogs.1637052703.txt.gz · Last modified: 2023/09/29 07:01 (external edit)