How to check error logs in Linux?
To view the error logs of a Linux system, you can use the following method:
- View kernel logs using the dmesg command.
- System log
- View system logs using the journalctl command.
- view system logs
- Common log files to check in the /var/log directory include:
- /var/log/syslog is the system log file.
- The log file for authentication is located at /var/log/auth.log.
- The kernel log file can be found at /var/log/kern.log.
- Error logs of Apache can be found in the file /var/log/apache2/error.log.
- Nginx error log file located at /var/log/nginx/error.log.
- error.log file in /var/log/mysql: MySQL error log file
- Universal log file located at /var/log/messages.
- You can use either the cat command or the less command to view the contents of the log file, for example:
- Display the contents of the syslog file at /var/log/syslog
- Depending on the specific application, review the application’s log files. Different applications may have different log file paths and naming conventions.
- For example, to view the error log file of Apache:
- View the error log for Apache2 located at /var/log/apache2/error.log.
- Viewing the error log file of Nginx:
- Display the contents of the error.log file in the Nginx directory.