Syslog protocol in detail

Syslog is a standard protocol used for logging system messages in Unix-based systems, providing a centralized way to manage and analyze logs. Understanding syslog facilities and levels is crucial for effective log management and troubleshooting.

When a program wants to log an event, it sends a message using the syslog protocol (often UDP port 514) to a syslog server. The syslog server then processes the message and writes it to a log file on the server.

The syslog protocol uses a simple and flexible message format that includes a few basic pieces of information:



  1. The severity level of the message, which indicates how important the message is.
  2. The time and date of the message.
  3. The hostname or IP address of the computer that sent the message.
  4. The name of the program or process that generated the message.
  5. The actual log message itself.



Syslog messages are categorized by facilities and levels. Facilities help in organizing log messages from different system processes, making it easier to filter and analyze them. Common syslog facilities include:



  • kern (0): Kernel messages
  • user (1): User-level messages
  • mail (2): Mail system
  • daemon (3): System daemons
  • auth (4): Security/authorization messages
  • syslog (5): Internal syslog messages
  • lpr (6): Line printer subsystem
  • news (7): Network news subsystem
  • uucp (8): UUCP subsystem
  • cron (9): Clock daemon (cron and at)
  • authpriv (10): Security/authorization messages (private)
  • ftp (11): FTP daemon
  • ntp (12): NTP subsystem
  • audit (13): Log audit
  • alert (14): Log alert
  • clock (15): Clock daemon (other)
  • local0-local7 (16-23): Locally used facilities, customizable by the user



Syslog levels indicate the severity of the log messages. The eight standard severity levels are:



  • Emergency (0): System is unusable
  • Alert (1): Action must be taken immediately
  • Critical (2): Critical conditions
  • Error (3): Error conditions
  • Warning (4): Warning conditions
  • Notice (5): Normal but significant conditions
  • Informational (6): Informational messages
  • Debug (7): Debug-level messages



Each level encompasses the levels below it. For example, if you configure your syslog to log at the "Warning" level, it will include messages from "Warning" as well as "Error," "Critical," "Alert," and "Emergency."

Syslog messages are a combination of a facility and a level. For example, a message from the mail system with a warning condition would be identified as `mail.warning`. This combination allows for granular control over log messages, enabling the system administrator to filter and route messages based on their source and severity.

Syslog configuration files, like `/etc/rsyslog.conf` or `/etc/syslog.conf`, determine how messages are handled. Here’s an example configuration snippet:



# Log all kernel messages to /var/log/kern.log
kern.* /var/log/kern.log

# Log mail system messages to separate files
mail.info /var/log/mail.info
mail.warn /var/log/mail.warn
mail.err /var/log/mail.err

# Log all authpriv messages to a secure file
authpriv.* /var/log/secure

# Send all emergency messages to all users
*.emerg *

# Log all messages to a remote syslog server
*.* @192.168.1.1


In this example:

  • Kernel messages of any level are logged to `/var/log/kern.log`.
  • Mail messages are divided into different files based on their severity.
  • Authorization messages (private) are logged to a secure file.
  • Emergency messages are sent to all users.
  • All messages are forwarded to a remote syslog server at IP address 192.168.1.1.



Syslog's facilities and levels provide a robust framework for managing system logs, allowing for efficient organization, filtering, and analysis of log data. Understanding these concepts is essential for system administrators to maintain healthy and secure systems, ensuring that critical issues are identified and addressed promptly. By configuring syslog appropriately, you can gain valuable insights into system operations and enhance your ability to troubleshoot and resolve issues.





Posted in   syslog     by trunc_team

Simple, affordable, log management and analysis.