Logs in Amazon Linux
If you are using Amazon Linux for the first time after using other traditional Linux, you won’t find the log file in the /var
directory.
This is because Amazon Linux by default the logs are recorded using systemd-journald
and can be viewed using journalctl
commands as below:
journalctl
to view all logsjournalctl -r
to view logs in reverse orderjournalctl -u <service_name>
to view the logs of a specific service
If we want to have the actual log fies like any traditional linux distribution in /var/log/syslog
or /var/log/messages
files, the we can install rsyslog
package on Amazon Linux instance(s) as below:
- Install
rsyslog
:sudo yum install rsyslog
- Start the
rsyslog
service:sudo systemctl start rsyslog
- Enable
rsyslog
to start on boot:sudo systemctl enable rsyslog
After installation, rsyslog
will create and maintain log files in the /var/log
directory, including /var/log/messages
.
Thanks for reading.