The log files in a system is very important because contain information on all the activities happening on the system. The information includes kernel messages, system problems, and services. These files are produced automatically and monitor the system carefully. The log files are created by everything on your system from the login to operating any application. Most of the information obtained by the log files lies in the form of plain text or in ASCII therefore logs are very useful in troubleshooting the difficulties and errors occurring in the applications.
How to View and Monitor Log Files in Ubuntu 22.04
There are two different ways to view and monitor log files in Ubuntu 202.04
- Monitor and view log files from the terminal
- Monitor and view logs files by GUI method
Monitor and View Log Files from the Terminal
To view and monitor the log files, open the Linux/ Ubuntu terminal using the shortcut key from the keyboard “Ctrl+Shift+T”. Now execute the below-given command to view log files.
dmesg
The above command gives the Kernal memory and all stored messages as output given below in the figure.

Sometimes the above command does not work, to make it work properly execute the below given command first.
sudo sysctl kernel.dmesg_restrict=0
The above-given command removes the restriction for the “dmesg” command to execute properly.

Use “cat” Command
The “cat” command is used to view the system log files. The command to be executed for this purpose is given as
cat /var/log/syslog
In the above command “var/log/syslog” is the directory location where the log files are located.


To manually input any messages in the log you use the below command
logger "This is a custom message"

When you put your manual message in the log then use the “cat” command again to view it.

To list the directories of the log use the below given command
cd /var/log

To see the log files in text format use the below given command.
sudo tail /var/log/syslog

To see the CRON Logs
The CORN log of Linux/Ubuntu is obtain by execution the below given command
grep CRON /var/log/syslog

To see the NetworkManager logs
To see the Network Manager logs in Linux/Ubuntu the command to be executed is given as
journalctl /usr/sbin/NetworkManager
In the above command “journalctl” is used to see the log file in journald.

To see the Startup logs
To see the Startup logs in Linux/Ubuntu the command to be executed is given as
journalctl -b
In the above command “-b” gives the boot log as output.

To see the SSH Logs
To see the last log in Linux/Ubuntu the command to be executed is given as
grep sshd /var/log/auth.log | less
To see the last logins Logs
To see the last log in Linux/Ubuntu the command to be executed is given as
lastlog | less

To see log of a specific time frame
The command to be executed to view the log files in a specified time frame is given as
journalctl --since "2 hours ago"

You can also see the logs of different dates by executing the below-given command
journalctl --since "2022-07-21 23:15:00" --until "2022-07-21 23:20:00"

To edit or make changes in the log files use the below command, by using this command terminal is acts like just an editor.
nano test.log
In the above command “nano” is used to convert the terminal to the text editor.

To analyze the log in a filtered and easy way use the below-given command
grep -i SiS /var/log/kernal.log
In the above command “grep -i” is used to give the output of the log files which contain the “sis” in their name.

For the real-time visualization of log files the command to be executed is given as
tail -f /var/log/kern.log
In the above command “tail -f” allows you to read the last ten lines of the files.

Monitor and View Log Files by GUI Method
To view the log files by GUI method you need to access the file manager. Firstly search for the Ubuntu software center, open it, and search for the log. It shows two two log options such as “Logs” and “System Log”.

Now open the “logs” from the search bar by simply searching and clicking to open it.

Now click on the “System” by simply clicking on it to see the system log files.

You can also see the log date-wise by just clicking on the Logs option shown at the top middle. By clicking on it a dropdown box will appear to choose the date of your requirement to see the log on that date. This result is shown in the figure below.

There is a huge list of log files given, if you want to search for specific files there is an option given to search it. You need to click on the search option and type the name of your required file.

Through KSystem Logs
Open the Ubuntu software center search for the “KSystemLog” and install it on your system.

Now open the KSystemLog and click on “Logs”. A dropdown box will appear on the screen which gives the option to view and monitor different logs, such as “System Log”, “Kernel Log”, “Authentication Log”, and “Services”.

By clicking on any option from the “Logs” you can see and monitor those logs, for example, click on the “Authentication Log”.

You can also search for any desired log by typing the “Ctrl+F” shortcut key from the Keyboard and giving the name of the log.

Conclusion
There are two methods available to view and monitor the log files in Linux/Ubuntu such as by using the GUI method to view log files and using the Linux/Ubuntu terminal to view the log files. In the first method, you use different commands such as “dmseg” “cat” and others to visualize the log files. In the GUI method, you search for the “log” from the search bar and open it to view the log files.