LoggingThe Ultimate Guide

your open-source resource for understanding, analyzing, and troubleshooting system logs

curated byloggly


Linux Logging Basics

First, we’ll describe the basics of what Linux logs are, where to find them, and how they get created. If you already know this stuff, feel free to skip to the next section.

Linux System Logs

Many valuable log files are automatically created for you by Linux. You can find them in your /var/log directory. Here is what this directory looks like on a typical Ubuntu system:

Linux system log terminal

Some of the most important Linux system logs include:

  • /var/log/syslog or /var/log/messages stores all global system activity data, including startup messages. Debian-based systems like ubuntu store this in /var/log/syslong. Redhat-based systems like rhel or centos store this in /var/log/messages.
  • /var/log/auth.log or /var/log/secure stores logs from the pluggable authentication module (PAM), including successful logins, failed login attempts, and authentication methods.Ubuntu and Debian store authentication messages in /var/log/auth.log redhat and centos store this data in /var/log/secure.
  • /var/log/kern stores kernel error and warning data, which is particularly helpful for troubleshooting custom kernels.
  • /var/log/cron stores information about cron jobs. Use this data to verify that your cron jobs are running successfully.

Digital Ocean has a thorough tutorial on these files and how rsyslog creates them on common distributions like RedHat and CentOS.

Applications also write log files in this directory. For example, popular servers like Apache, Nginx, MySQL, and more can write log files here. Some of these log files are written by the application itself. Others are created through syslog (see below).

How do Linux system log files get created? The answer is through the syslog daemon, which listens for log messages on the syslog socket /dev/log and then writes them to the appropriate log file.

What’s Syslog?

The word “syslog” is an overloaded term and is often used in short to refer to one of these:

  1. Syslog daemon— a program to receive, process, and send syslog messages. It can send syslog remotely to a centralized server or write it to a local file. Common examples include rsyslogd and syslog-ng. In this usage, people will often say “sending to syslog.”
  2. Syslog protocol— a transport protocol specifying how logs can be sent over a network and a data format definition for syslog messages (below). It’s officially defined in rfc-5424. The standard ports are 514 for plaintext logs and 6514 for encrypted logs. In this usage, people will often say “sending over syslog.”
  3. Syslog messages— log messages or events in the syslog format, which includes a header with several standard fields. In this usage, people will often say “sending syslog.”

Syslog messages or events include a header with several standard fields, making analysis and routing easier. They include the timestamp, the name of the application, the classification or location in the system where the message originates, and the priority of the issue.

Here is an example log message with the syslog header included. It’s from the sshd daemon, which controls remote logins to the system. This message describes a failed login attempt:

Syslog Format and Fields

Each syslog message includes a header with fields. Fields are structured data that makes it easier to analyze and route the events. Here is the format we used to generate the above syslog example.

You can match each value to a specific field name.

Below, you’ll find descriptions of some of the most commonly used syslog fields when searching or troubleshooting issues.


Below, you’ll find descriptions of some of the most commonly used syslog fields when searching or troubleshooting issues.


The timestamp field (2003-10-11T22:14:15.003Z in the example) indicates the time and date the message was generated on the system sending the message. That time can be different from when another system receives the message. The example timestamp breaks down like this:

  • 2003-10-11is the year, month, and day.
  • Tis a required element of the timestamp field, separating the date and the time.
  • 22:14:15.003 is the 24-hour format of the time, including the number of milliseconds (003) into the next second.
  • Z is an optional element, indicating UTC time. Instead of z, the example could have included an offset, such as -08:00, which indicates that the time is offset from UTC by eight hours, PT.


The hostname field (server1.com in the example above) indicates the name of the host or system that sent the message.


The app-name field (sshd:auth in the example) indicates the name of the application that sent the message.


The priority field or pri for short (<34> in the example above) tells you how urgent or severe the event is. It’s a combination of two numerical fields: the facility and the severity. The severity ranges from the number 7 for debug events all the way to 0 which is an emergency. The facility describes which process created the event. It ranges from 0 for kernel messages to 23 for local application use.

Pri can be output in two ways. The first is as a single number, prival, which is calculated as the facility field value multiplied by eight, then the result is added to the severity field value: (facility)(8) + (severity). The second is pri-text, which will output in the string format “facility.severity”. The latter format can often be easier to read and search, but takes up more storage space.

Written & Contributed by



#Linux logs 101 - what are they, where to find them and how they get created: http://bit.ly/1N8WsBG @loggly

This guide will help software developers and system administrators become experts at using logs to better run their systems. This is a vendor-neutral, community effort featuring examples from a variety of solutions

Meet Our Contributors Become a contributor