Understanding Log Files on your Linux System
Log files in Linux represent point in time events for activity related to the OS, system devices, and applications running on the system. Learn how to leverage logs to troubleshoot issues, debug applications, and keep servers reliable at all times.
/var/log
to store files for several key OS services, and applications. Contents may vary across distributions, but a typical list view of what is found inside is similar to the following,
/var/log/syslog
which stores global system activity like notices and alerts generated at server boot time. The actual log name depends on the Linux variant, but generally Ubuntu systems usesyslog
, while other distros like Amazon Linux and CentOS use the name/var/log/messages
./var/log/auth.log
for storing security-related events such as failed login attempts, user password updates, and package installs performed by the root user. You can think of this log file as the system of record for activity requiring approval from pluggable authentication modules (PAM). Ubuntu uses the fileauth.log
, while Amazon Linux and CentOS use/var/log/secure
./var/log/kern.log
stores low-level system activity records for disk management, memory, and system tasks. The entries found in this log includes kernel events, errors, and warnings, which can be helpful for troubleshooting custom configurations./var/log/cron
stores information aboutcron
jobs which are tasks configured to run on a set schedule. An example would be an operation that runs every Sunday at 4:00AM to perform data backups. The information captured in the cron log verifies if a task runs as scheduled as well as the output results from the job.
./cups
sub-directory, and information captured by web servers is written to ./apache2
. Developers simply modify the code so that output is written to a location most suited for the application. As a best practice, developers can use a unique sub-directory to manage logs associated with each application. Two very important utilities found in the /var/log
directory are syslog
and dmesg
.- The syslog protocol RFC 5424, which is a transport protocol that specifies how to transmit logs over the network. It is also the data format that defines the structure of a message. By default, syslog uses ports
514
for plaintext and6514
to encrypt messages requiring additional security. - The syslog daemon process, for receiving and processing system messages. It listens for events through
/dev/log
, where applications write message details. Because of its flexibility, the daemon can write locally to the system or to a remote server making it possible to centralize event logs across a distributed, multi-server environment. There are different implementations of syslog including rsyslogd and syslog-ng. - The syslog message, which is an event record structured using the syslog message format. A message is comprised of a standard header and body containing complete details about an event.


journalctl
is a utility to query and display journald logs.man journalctl
via the command line for more info and options on how to manage system logs.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.