How to check error logs in Linux?
To check the error log, you can use the following command:
- Check the system log (syslog):
- Monitor system log files in real-time by using “tail -f /var/log/syslog”.
- Check the entire content of the system log file by using the command “cat /var/log/syslog.”
- View application logs:
- Check the Apache web server’s error log in real-time by using the “tail -f” command, for example: tail -f /var/log/apache2/error.log.
- Use the cat command to view the entire log file, for example: cat /var/log/apache2/error.log to check the error logs of the Apache web server.
- View the logs for a specific service.
- The log files for each service may be stored in different locations, typically under the /var/log directory. You can use the command ls /var/log to see available log files.
- Common service log file locations include:
Apache web server: /var/log/apache2/error.log or /var/log/httpd/error_log
Nginx web server: /var/log/nginx/error.log
MySQL database: /var/log/mysql/error.log
SSH server: /var/log/auth.log
Please note that the above command may require administrator privileges (sudo) to execute.