Image

Knowledge base → View and search for events in log files

[Virtual servers] [Shared hosting]
Date of publication: 08.10.2023

To view the log file and search for events, use the following commands:

1. To change the root folder

cd /var/log/nginx/

2. View a list of files and folders located in a given directory

ls

2.1 View a list of files and folders showing rights and owner

ls -la

3. View file contents, use Enter key to scroll

more /var/log/nginx/error.log

3.1 Viewing the contents of a file based on the presence of an expression (search-text)

more /var/log/nginx/error.log | grep search-text

4. Dynamic file preview in real time (use Ctrl + c combination to exit)

tail -f /var/log/nginx/access.log

4.1 Dynamic viewing of a file in real time, taking into account the presence of an expression, is especially convenient when there are a lot of events, but you need to do filtering, where xxx.xx.xxx.xx is the IP address of interest. Data including this expression will be displayed.

tail -f /var/log/nginx/access.log | grep xxx.xx.xxx.xx




No Comments Yet