Log monitoring

Monitor server logs

Production, verification, development, whatever Logs are written more and more in the server.log-like file of the AP server. To monitor system movements that are not visible from the outside, such as whether the module is working properly You have to monitor the log every time you release it, right?

At that time, I connect to the linux server with TeraTerm etc. and see the log file. Which command do you use? Is a story

Royal road tail

Well this is it tail -f file path For example

tail -f /asd/asdasdasd/asdasdasd/server.log

Like Now you can monitor the overwritten files in real time

New era less

Nowadays tail is weak less + F file path For example

less +F /sdd/sdsdsd/sdsdsd/server.log

This has the same functionality as tail -f Stop updating with Ctrl + C What if

less /sdd/sdsdsd/sdsdsd/server.log

Just type shift + f (uppercase F) after executing

So you can do something like Grep

If you enter & in the non-update mode, an input field will appear. Enter the word "exact match" or "qqq | eee" there to search OR It's case sensitive so type it correctly

Also, if you enter ! after entering &, you will be in not-match mode (mismatch search).

You can download the log file locally and search it on the spot without having to use Grep with the Sakura editor.

Moreover, if you are in a mode that does not update automatically, press B key to the top page, Space key to the bottom page, G key to the top, Shift + G key to the bottom You can fly at once

It is no exaggeration to say that less is upward compatible with tail.

For Windows

Let's start Power-Shell You should be able to do it with the A key from the win key + X key

And

Get-Content -wait -tail 10 -encod UTF8 -path path

The 10 part here is the number of lines to get first, if you do not specify tail -f, it is 10 at the beginning, so I wrote 10

Recommended Posts

Log monitoring
Log monitoring script
[Linux] Log monitoring
Log message monitoring shell
python log
Winning with Monitoring
[blackbird-td-agent] Monitoring td-agent