When a switch port goes down and back up at 03:12 at night, when an OSPF adjacency drops, or when someone changes the configuration without authorization, the trace stays in the device’s local log buffer. The buffer fills up or the device restarts. The trace is gone. Below, from a network operations perspective, we explain how to collect the logs of switches, routers, firewalls and wireless access points on a central rsyslog-based server, make timestamps consistent and size the retention space.
The role of central logging in network operations
A central syslog server gives the network team three things: a persistent record even if the device restarts, correlation of events from multiple devices on the same timeline, and a single event source that can be connected to the monitoring system. Seeing that a spanning tree topology change on the core switch and port flaps on the access layer started in the same minute is only possible if logs are kept in one place and with the same clock. During an outage, this should be the first window opened on the console.
The scope here is network operations: fault diagnosis, change tracking, capacity and hardware alerts. Correlation of security events, SIEM integration and regulatory retention periods are a separate design topic; for that side, refer to the central log retention architecture guide. The two structures can be connected: the network syslog server can keep logs locally while forwarding a copy to the SIEM. When security detection and correlation are needed on top of log retention, see our SIEM setup and security logs service.
Syslog severity levels and facility selection
The priority of syslog messages is expressed with the eight severity levels defined in RFC 5424. The level selected on the device means that all messages of that level and more important (numerically smaller) levels are sent.
| Code | Level | Typical example on a network device |
|---|---|---|
| 0 | Emergency | System is unusable |
| 1 | Alert | Condition requiring immediate action |
| 2 | Critical | Memory allocation failure, hardware fault |
| 3 | Error | Interface state change (Cisco LINK-3) |
| 4 | Warning | Port err-disabled, MAC flapping |
| 5 | Notice | Protocol adjacency, configuration change |
| 6 | Informational | ACL log matches, session information |
| 7 | Debug | Only during troubleshooting |
For sending to the central server, informational (6) is usually the right level. Stopping at notice leaves out useful information such as ACL log lines. Debug, on the other hand, is never enabled permanently toward the central server; it quickly consumes both device CPU and disk. You may come across debugs enabled “temporarily” and forgotten for months.
The facility field is used to classify messages on the receiving side. Network devices usually use one of the local0–local7 range (the Cisco IOS default is local7). Assigning different facilities by device type (such as local5 for switches, local4 for firewalls) makes filtering in rsyslog easier; still, in a modern rsyslog configuration, splitting by source IP is more reliable.
Time consistency: NTP and timestamp settings
You can’t correlate logs with inconsistent timestamps; if you do, it leads to the wrong conclusion. All devices should synchronize to the same NTP source (preferably two NTP servers on the internal network) and add milliseconds and time zone information to the log line. Use UTC on devices, or a single local time zone across the whole network. Mixed use is the most common mistake we see.
The syslog server also records the time the message was received. If there is a systematic difference between the device time and the receive time, NTP synchronization is broken. On Cisco, show ntp status and show ntp associations are enough to check.
Sending logs from Cisco IOS and other devices
The Cisco IOS/IOS XE example below defines NTP, timestamps, the local buffer and sending to the central server together:
clock timezone TRT 3 0
ntp server 10.10.99.1
ntp server 10.10.99.2
!
service timestamps log datetime msec localtime show-timezone
service sequence-numbers
!
logging buffered 64000 informational
logging source-interface Loopback0
logging facility local5
logging trap informational
logging origin-id hostname
logging host 10.10.99.30
!
! Sending over TCP (if the platform supports it)
! logging host 10.10.99.30 transport tcp port 514
service sequence-numbersadds a sequence number to each message. It’s the only way you notice UDP losses.logging source-interfaceensures messages always leave from the same management address; per-device file separation in rsyslog relies on this address.logging bufferedkeeps a local copy at moments when the central server is unreachable.- The TCP port must be the same on both sides. In the IANA registry, 514/tcp belongs not to syslog but to rsh; still, many products use 514 for TCP syslog. In Cisco IOS, if no port is specified with
transport tcp, the default is 601. Set the port rsyslog listens on accordingly; in a “UDP works, logs stopped after switching to TCP” situation, look for this mismatch first.
The logic is the same for other vendors: target server, level, source interface and NTP. On wireless controllers and cloud-managed APs, syslog is usually defined via the controller or cloud dashboard; in that case, account for the logs coming from the controller, not the AP.
The receiving server with rsyslog: UDP/TCP, per-device files
rsyslog, which ships with most Linux distributions, is a sufficient receiver for network devices. The configuration below separates remote logs from the server’s own logs and opens a separate file for each device. Save the file as /etc/rsyslog.d/10-network.conf:
module(load="imudp")
module(load="imtcp")
template(name="NetDevFile" type="string"
string="/var/log/network/%FROMHOST-IP%.log")
ruleset(name="netdevices") {
action(type="omfile" dynaFile="NetDevFile"
dirCreateMode="0750" fileCreateMode="0640")
stop
}
input(type="imudp" port="514" ruleset="netdevices")
input(type="imtcp" port="514" ruleset="netdevices")
Using a separate ruleset prevents remote messages from mixing into /var/log/messages or /var/log/syslog. Using %FROMHOST-IP% in the file name instead of the hostname sent by the device is a deliberate choice: some devices fill the hostname field in a non-standard way. The IP–device name mapping is kept in documentation or DNS.
Then validate the configuration, restart the service and send a test message:
rsyslogd -N1 # syntax check
systemctl restart rsyslog
firewall-cmd --permanent --add-port=514/udp --add-port=514/tcp
firewall-cmd --reload
logger -n 10.10.99.30 -P 514 -d "syslog receive test" # UDP test
tcpdump -ni any port 514 # observe packets arriving from devices
UDP 514 provides broad compatibility but no delivery guarantee. The logs lost during network congestion are exactly the logs you’ll need. If the device supports it, prefer TCP; if traffic crosses an untrusted network segment, consider syslog over TLS (RFC 5425). Give access to the syslog server only from the management network.
Retention period, logrotate and disk sizing
Per-device files are rotated with logrotate. Example /etc/logrotate.d/network:
/var/log/network/*.log {
daily
rotate 180
compress
delaycompress
missingok
notifempty
sharedscripts
postrotate
systemctl kill -s HUP rsyslog.service
endscript
}
This configuration keeps 180 days of history; set the period according to your organization’s policy. An example calculation for disk size: assuming 150 devices, an average of 4,000 messages per device per day and 200 bytes per message, the daily raw volume is 150 × 4,000 × 200 = 120 MB; the uncompressed total for 180 days comes to about 21.6 GB. Text logs typically shrink several times with gzip; measure the ratio on your own data. The real risk isn’t the average but sudden spikes. A loop or a flapping uplink can produce thousands of messages within minutes. That’s why /var/log/network should be placed on a separate file system and its usage monitored; when the log disk fills up, the server’s own services shouldn’t be affected.
Critical network log messages that should raise alarms
Collecting logs is half the job. Certain messages should land in the monitoring system as alarms. The Cisco message types below are a good starting list for network operations; map other vendors’ equivalent messages with the same logic:
| Message | Meaning | Recommended response |
|---|---|---|
| %LINK-3-UPDOWN (uplink) | Uplink or trunk went down | Immediate alarm |
| %PM-4-ERR_DISABLE | Port became err-disabled | Alarm + cause investigation |
| %SW_MATM-4-MACFLAP_NOTIF | MAC address is jumping between ports | Suspected loop, urgent |
| %SPANTREE-2-BLOCK_BPDUGUARD | BPDU received on an access port | Check for unauthorized switch |
| %OSPF-5-ADJCHG, %BGP-5-ADJCHANGE | Routing adjacency changed | Alarm, track repeat count |
| %SYS-5-CONFIG_I | Configuration changed | Compare with change record |
| %SEC_LOGIN-4-LOGIN_FAILED | Failed login | Threshold-based alarm |
| %SYS-2-MALLOCFAIL | Memory allocation failure | Critical, device investigation |
Not every LINK-3-UPDOWN message on access ports should be an alarm; user computers powering on and off produce this message. To limit the alarm rule to uplink, server and trunk ports, use consistent naming in port descriptions; writing the rule becomes easier that way. Combining SYS-5-CONFIG_I messages with versioned configuration backups closes the question “who changed what, and when”; the setup is in the configuration backup with Oxidized article. To connect logs to a monitoring platform, see the network monitoring software comparison article; for diagnosing slowness with log evidence, see troubleshooting network slowness.
Setting up syslog, NTP and the monitoring infrastructure together and reviewing them periodically is within the scope of the network maintenance, monitoring and periodic checks service.
Frequently asked questions
Should syslog use UDP or TCP?
UDP 514 offers the widest compatibility but no delivery guarantee; messages can be lost during congestion. If the device supports it, prefer TCP; if traffic crosses an untrusted network segment, consider syslog over TLS.
Which log level should be chosen on devices?
For sending to the central server, informational (6) is usually the right balance. The debug level is enabled only during troubleshooting and temporarily; it isn’t sent to the central server permanently.
How long should logs be kept?
For network operations, the period is set by how far back you need to look in fault and change investigations. Retention obligations arising from security and regulation should be assessed separately and written into the organization’s policy.
Why do log files use the IP address instead of the hostname?
Some network devices fill the hostname field in the syslog message in a non-standard way or leave it empty. When the source IP is pinned with logging source-interface, it identifies the device reliably; the mapping between IP and device name is kept in documentation or DNS.