Skip to content

Syslog Rsyslog and Logrotate


The journal covers a lot of ground, but it isn’t the only logging mechanism running on a typical Debian or Ubuntu system — and it isn’t a full replacement for the older approach either. This chapter covers syslog, the traditional standard still very much in active use, why it coexists with the journal rather than being replaced by it, and logrotate, the tool that keeps the resulting log files from growing forever.

Syslog: A Standard, Not A Program

“Syslog” refers to a logging standard — a defined message format and a set of severity levels — not any single piece of software. You’ve actually already met syslog’s severity levels without the name attached: the emerg through debug priority scale from the journalctl chapter is the same scale syslog originally defined, which systemd’s journal adopted directly rather than inventing its own.

On Debian and Ubuntu, the program actually implementing this standard is rsyslog — a daemon that receives log messages and writes them out as traditional, plain-text files under /var/log, the same directory referenced back when this course first covered the Filesystem Hierarchy Standard.

Why Both journald And rsyslog Exist Together

This is worth explaining directly rather than leaving as an unexplained coincidence: on a typical Debian or Ubuntu install, systemd-journald receives log messages first, then forwards a copy of them to rsyslog, which writes them out in the traditional plain-text format. Both are genuinely running, doing genuinely different jobs with the same underlying data.

Actually systemd-journald on a typical system, only starts after syslog.socket is ready:

systemctl cat systemd-journald | grep syslog
After=systemd-journald.socket systemd-journald-dev-log.socket systemd-journald-audit.socket syslog.socket

journald’s strength is structure — every entry carries metadata (unit, priority, boot ID) that makes precise filtering possible, exactly as covered in the last chapter. rsyslog’s strength is compatibility and reach — plenty of existing tools, scripts, and monitoring systems expect plain text log files in /var/log, and rsyslog can also forward logs to a remote logging server over the network, something the journal alone isn’t built around. In a real infrastructure with many servers, centralizing logs onto one dedicated log server is a common, genuinely important practice — outside the hands-on scope of this chapter, but worth knowing rsyslog is the piece that makes it possible.

    flowchart LR
    A["Kernel & services"] --> B["systemd-journald"]
    B --> C["Structured journal<br/>(journalctl)"]
    B --> D["rsyslog"]
    D --> E["/var/log/*.log<br/>plain text files"]
    D -.->|"optional"| F["Remote log server"]
  

Where rsyslog’s Configuration Lives

cat /etc/rsyslog.conf
ls /etc/rsyslog.d/

Following a pattern you’ve seen before in this course — a main configuration file plus a .d directory of smaller, focused snippets — /etc/rsyslog.conf holds the core configuration, while /etc/rsyslog.d/ holds additional rules, often one file per package or purpose, without needing to edit the main file directly.

Reading A Basic rsyslog Rule

A rule follows a facility.priority action shape:

mail.*                          /var/log/mail.log
auth,authpriv.*                 /var/log/auth.log
kern.*                          /var/log/kern.log

Facility describes the general source or category of a message — a fixed, standard set of categories syslog defines:

FacilityTypical source
auth / authprivAuthentication and login events
cronScheduled task activity
daemonBackground services without a more specific facility
kernKernel messages
mailMail system activity
syslogrsyslog’s own internal messages

Priority is the same emerg through debug scale already covered — * means “any priority.” So auth,authpriv.* reads as: any message from the authentication facilities, at any priority level, gets written to /var/log/auth.log.

Common Log Files And What Generates Them

sudo tail -f /var/log/auth.log

Watching login attempts and sudo usage in real time — directly useful given everything covered in the Privilege Escalation chapter, since every sudo invocation logs here.

sudo less /var/log/syslog

The general catch-all log on Debian-family systems — messages that don’t have a more specific dedicated log file end up here. Every reading tool from earlier in this course — less, grep, tail -f — works on these exactly the way it would on any other plain text file, since that’s genuinely all they are.

logrotate: Keeping Log Files From Growing Forever

Left unmanaged, files like /var/log/syslog would simply grow without bound for as long as the system runs — eventually consuming meaningful disk space with old, rarely-needed historical data. logrotate solves this: periodically, it renames the current log file, starts a fresh empty one in its place, and eventually deletes or compresses the oldest rotated copies once enough time has passed.

ls /etc/logrotate.d/

Like rsyslog, logrotate configuration is split across a main file (/etc/logrotate.conf) and a directory of per-service snippets, typically installed automatically alongside whatever service they apply to.

A typical entry:

/var/log/myapp/*.log {
    weekly
    rotate 4
    compress
    missingok
    notifempty
}
  • weekly — rotate on this schedule (daily and monthly are the other common options)
  • rotate 4 — keep 4 old rotated copies before deleting the oldest
  • compress — gzip rotated copies to save space
  • missingok — don’t error out if the log file doesn’t exist yet
  • notifempty — skip rotating if the file is currently empty, avoiding pointless empty rotated files

Testing A Rotation Manually

Waiting for the actual schedule to test a new logrotate configuration is impractical — force it to run immediately instead:

sudo logrotate -f /etc/logrotate.conf

-f forces rotation regardless of whether the configured schedule or size threshold has actually been met — the right way to confirm a new configuration behaves as expected before trusting it to run unattended on its normal schedule.

A Long Cheatsheet Of Log Files

It is impossible to remember. Don’t even try. Take it as a reference:

Log FileGenerated ByWhat It Records / Purpose
/var/log/syslogSystem services, daemons, and applications through the syslog systemGeneral-purpose system log. It can contain messages from many different parts of the system, including services, applications, networking, scheduled tasks, and other system components. Common on Debian/Ubuntu systems.
/var/log/messagesSystem services, daemons, and applicationsGeneral system messages, warnings, errors, and informational events. Common on RHEL/CentOS/Fedora systems and serves a role similar to /var/log/syslog.
/var/log/auth.logAuthentication system / PAM / SSH / sudoAuthentication and authorization events such as successful and failed logins, SSH authentication, sudo usage, PAM activity, and other authentication-related events. Common on Debian/Ubuntu.
/var/log/secureAuthentication system / PAM / SSH / sudoAuthentication and authorization events similar to /var/log/auth.log. Common on RHEL/CentOS/Fedora.
/var/log/kern.logLinux kernelMessages generated by the kernel itself, including kernel warnings, errors, device/driver events, and other kernel-level activity.
/var/log/dmesgLinux kernel / dmesgKernel ring-buffer messages, particularly useful for hardware detection, device drivers, boot-time kernel activity, USB devices, disks, network interfaces, and other hardware-related events. On many modern systems, dmesg is primarily a command that reads the kernel ring buffer rather than a persistent log file.
/var/log/boot.logSystem boot process / init systemMessages generated while the operating system is starting. Useful for investigating services or components that failed to start during boot.
/var/log/cronCron daemonRecords the execution of scheduled jobs managed by cron, including when cron jobs start and other cron-related activity.
/var/log/maillogMail services / mail daemonRecords mail-system activity such as SMTP connections, email delivery attempts, rejected messages, delivery failures, and other mail-server events.
/var/log/audit/audit.logLinux Audit subsystem (auditd)Detailed security/auditing events. Can record system calls, file access, permission changes, authentication events, process activity, security-policy violations, and other events according to the configured audit rules.
/var/log/faillogLogin/authentication subsystemMaintains failed-login information associated with user accounts. It is primarily concerned with per-user failed-login statistics/status, rather than serving as a detailed chronological event log.
/var/log/btmpLogin/authentication subsystemStores individual failed-login records. It can contain information about failed login attempts, such as the username, time, terminal, and remote host. The lastb command is commonly used to read this file.
/var/log/wtmpLogin/accounting subsystemStores records of successful login and logout sessions, as well as events such as system boots and shutdowns. The last command commonly reads this file.
/var/run/utmpLogin/session subsystemContains information about currently active login sessions/users. Unlike wtmp, which is historical, utmp represents current session state. Commands such as who, w, and users use this information.
/var/log/lastlogLogin/PAM subsystemStores information about the most recent successful login for each user. Unlike wtmp, it is organized around each user’s last login rather than being a general chronological history of all sessions. The lastlog command reads it.
/var/log/ufw.logUFW firewallRecords firewall activity handled by UFW, particularly packets/connections that are allowed, denied, or otherwise logged by configured firewall rules.
/var/log/journal/systemd-journaldPersistent binary journal containing system, kernel, service, authentication, and other logs collected by systemd-journald. Normally queried using journalctl rather than read as plain text.
/var/log/Xorg.0.logX.Org display serverRecords activity from the X.Org graphical display server, including display initialization, graphics hardware, drivers, input devices, display configuration, and graphics-related errors.

The Confusing Authentication/Login Logs

This distinction matters:

LogThink of it asWhat makes it different
/var/log/auth.log“What happened with authentication?”Broad authentication log: SSH, sudo, PAM, login attempts, authentication failures, etc.
/var/log/secureSame as auth.log, but on RHEL-family systemsDistribution-specific equivalent commonly used instead of auth.log.
/var/log/faillog“Failed-login information for each user”Focuses on per-account failed-login information/statistics rather than being a detailed chronological event history.
/var/log/btmp“Show me the failed login events”Stores individual failed-login records. lastb is used to display them.
/var/log/wtmp“Who successfully logged in/out?”Historical login/logout/session accounting, including reboots. last reads it.
/var/run/utmp“Who is logged in right now?”Current/active sessions rather than historical login history. who and w read it.
/var/log/lastlog“When did each user last successfully log in?”One user’s most recent successful login information rather than a complete login history.

What’s Next

Between the journal and traditional syslog-based logging, you can now find and manage essentially anything a Linux system records about itself. The next chapter shifts to a different kind of automation entirely — running tasks on a schedule, with cron.

Last updated on