Logging Configuration
Logging Configuration
Section titled âLogging ConfigurationâTL;DR (Quick Start)
Section titled âTL;DR (Quick Start)âFor the impatient: send logs to a remote syslog server.
/system logging action set [find name=remote] remote=192.168.1.100/system logging add action=remote topics=info/system logging add action=remote topics=warning/system logging add action=remote topics=errorVerify with:
/log print followOverview
Section titled âOverviewâWhat this does: RouterOS logging captures system events and status information for monitoring, troubleshooting, and auditing. Logs can be stored in memory (RAM), written to disk files, displayed on console, sent via email, or transmitted to remote syslog servers.
When to use this:
- Real-time monitoring of router events
- Troubleshooting connectivity or configuration issues
- Security auditing (login attempts, firewall matches)
- Centralized log collection from multiple routers
- Compliance and forensic analysis via SIEM integration
Prerequisites:
- Network connectivity to syslog server (for remote logging)
- Email server configuration (for email alerts)
- Sufficient storage space (for disk logging)
Configuration Steps
Section titled âConfiguration StepsâStep 1: View Current Logs
Section titled âStep 1: View Current LogsâBefore configuring logging, check the existing log entries stored in memory.
/log printTo monitor logs in real-time:
/log print followPress Ctrl+C to stop following.
Step 2: Review Default Configuration
Section titled âStep 2: Review Default ConfigurationâRouterOS includes five default logging actions that cannot be deleted.
/system logging action printExpected output:
Flags: * - default # NAME TARGET REMOTE 0 * memory memory 1 * disk disk 2 * echo echo 3 * remote remote 0.0.0.0 4 * email emailView the default logging rules:
/system logging printStep 3: Configure Remote Syslog
Section titled âStep 3: Configure Remote SyslogâSet the syslog server address on the default remote action.
/system logging action set [find name=remote] remote=192.168.1.100Important: Create separate rules for each severity level. Topics are ANDed together, so topics=info,warning,error will match nothing (no log entry has all three severities simultaneously).
/system logging add action=remote topics=info/system logging add action=remote topics=warning/system logging add action=remote topics=error/system logging add action=remote topics=criticalStep 4: Verify Configuration
Section titled âStep 4: Verify ConfigurationâConfirm the logging rules are active.
/system logging printExpected output:
Flags: X - disabled, * - default # TOPICS ACTION PREFIX 0 * info memory 1 * error memory 2 * warning memory 3 * critical echo 4 info remote 5 warning remote 6 error remote 7 critical remoteCommon Scenarios
Section titled âCommon ScenariosâScenario: Send Specific Topics to Syslog
Section titled âScenario: Send Specific Topics to SyslogâRoute only firewall and authentication events to the syslog server.
/system logging add action=remote topics=firewall/system logging add action=remote topics=account/system logging add action=remote topics=sshScenario: Custom Syslog Action with BSD Format
Section titled âScenario: Custom Syslog Action with BSD FormatâCreate a dedicated syslog action with custom facility for filtering.
/system logging action add name=syslog target=remote \ remote=192.168.1.100 remote-port=514 \ syslog-facility=local0 syslog-severity=auto \ syslog-time-format=bsd-syslog
/system logging add action=syslog topics=info/system logging add action=syslog topics=errorScenario: CEF Format for SIEM Integration (v7.18+)
Section titled âScenario: CEF Format for SIEM Integration (v7.18+)âSend logs in Common Event Format for SIEM systems.
/system logging action add name=siem target=remote \ remote=10.0.0.50 remote-port=514 remote-protocol=tcp \ remote-log-format=cef cef-event-delimiter="\r\n"
/system logging add action=siem topics=info/system logging add action=siem topics=firewallScenario: Disk Logging for Persistent Storage
Section titled âScenario: Disk Logging for Persistent StorageâStore logs to disk for retention after reboot.
/system logging action add name=disk-log target=disk \ disk-file-name=log disk-lines-per-file=1000 disk-file-count=5
/system logging add action=disk-log topics=firewallView disk log files:
/file print where name~"log"Scenario: USB/External Storage Logging
Section titled âScenario: USB/External Storage LoggingâAvoid NAND wear by logging to external USB storage.
/system logging action add name=usb-log target=disk \ disk-file-name=usb1/router-log disk-lines-per-file=5000 disk-file-count=10
/system logging add action=usb-log topics=firewall/system logging add action=usb-log topics=web-proxyScenario: Email Alerts for Critical Events
Section titled âScenario: Email Alerts for Critical EventsâReceive email notifications for critical system events.
First, configure the email server:
/tool e-mail set server=smtp.example.com port=587 \ start-tls=yes [email protected] password=yourpasswordThen create the email logging action:
/system logging action add name=email-alerts target=email \ [email protected] email-start-tls=yes
/system logging add action=email-alerts topics=critical/system logging add action=email-alerts topics=accountScenario: Separate Memory Buffer for Debugging
Section titled âScenario: Separate Memory Buffer for DebuggingâCreate isolated buffers for specific topics to simplify troubleshooting.
/system logging action add name=dhcp-debug target=memory memory-lines=500/system logging add action=dhcp-debug topics=dhcp
/log print where buffer=dhcp-debugScenario: Firewall Logging with Prefix
Section titled âScenario: Firewall Logging with PrefixâTrack specific firewall rule matches using prefixes.
First, add firewall rules with logging:
/ip firewall filter add chain=input action=drop log=yes log-prefix="DROP_INPUT:" \ connection-state=invalidThen create a logging rule (note: prefix adds text to messages, does not filter by prefix):
/system logging action add name=fw-drops target=memory memory-lines=2000/system logging add action=fw-drops topics=firewallScenario: VRF-Aware Remote Logging (v7.19+)
Section titled âScenario: VRF-Aware Remote Logging (v7.19+)âSend logs through a specific VRF.
/system logging action add name=mgmt-syslog target=remote \ remote=10.99.0.10 vrf=managementScenario: Multi-Router Centralized Logging
Section titled âScenario: Multi-Router Centralized LoggingâAssign different syslog facilities to each router for server-side filtering.
# Router 1/system logging action set remote syslog-facility=local0
# Router 2/system logging action set remote syslog-facility=local1
# Router 3/system logging action set remote syslog-facility=local2Verification
Section titled âVerificationâConfirm your logging configuration is working.
Check 1: Verify Remote Syslog Action
Section titled âCheck 1: Verify Remote Syslog Actionâ/system logging action print where target=remoteExpected: Remote address shows your syslog server IP.
Check 2: Verify Logging Rules
Section titled âCheck 2: Verify Logging Rulesâ/system logging printExpected: Rules showing your topics mapped to appropriate actions.
Check 3: Test Remote Logging with Packet Capture
Section titled âCheck 3: Test Remote Logging with Packet Captureâ/tool sniffer quick host=192.168.1.100 port=514Expected: UDP packets to syslog server when log events occur.
Check 4: Generate a Test Log Entry
Section titled âCheck 4: Generate a Test Log Entryâ:log info "Test message from RouterOS"Then verify it appears:
/log print where message~"Test message"Troubleshooting
Section titled âTroubleshootingâ| Symptom | Cause | Solution |
|---|---|---|
| Remote syslog not receiving logs | Firewall blocking UDP 514 | Check outbound firewall rules; allow UDP 514 |
| Remote syslog not receiving logs | Topics combined incorrectly | Create separate rules for each severity (info, warning, error, critical) |
| Remote syslog not receiving logs | Wrong syslog server IP | Verify with /system logging action print |
| Topics missing in syslog messages | BSD syslog format limitation | Use log prefix or different facilities per topic |
| Cannot clear memory logs | RouterOS version too old | Upgrade to v7.20+ or reduce memory-lines temporarily |
| Disk logs wearing out NAND | High-frequency logging | Use USB storage or remote syslog instead |
| Email alerts not sending | Email not configured | Configure /tool e-mail first |
| Reboot messages not in remote syslog | Network unavailable during boot | Use disk logging for system topic |
Common Mistakes
- Donât combine multiple severity levels in one rule -
topics=info,warning,errormatches nothing because topics are ANDed. Each log entry has only ONE severity level. - Donât confuse prefix behavior - The
prefixproperty adds text to messages, it does NOT filter by prefix. - Donât log high-frequency topics to internal NAND - Firewall and web-proxy topics can cause flash wear. Use external storage or remote syslog.
- Donât expect immediate remote logs during reboot - Network isnât available during early boot/late shutdown. Boot messages only go to memory/disk.
- Cannot delete default actions - The five default actions (memory, disk, echo, remote, email) cannot be deleted or renamed. Create new actions instead.
Log Topics Reference
Section titled âLog Topics ReferenceâSeverity Topics (one per log entry)
Section titled âSeverity Topics (one per log entry)â| Topic | Description |
|---|---|
critical | Critical system events |
error | Error conditions |
warning | Warning conditions |
info | Informational messages |
debug | Debug-level messages |
packet | Packet-level details |
raw | Raw packet data |
Common Facility Topics
Section titled âCommon Facility Topicsâ| Topic | Description |
|---|---|
account | User login/logout events |
bgp | BGP routing protocol |
dhcp | DHCP server/client events |
dns | DNS operations |
firewall | Firewall rule matches |
interface | Interface state changes |
ipsec | IPsec VPN events |
ospf | OSPF routing protocol |
ppp | PPP connections |
route | Routing table changes |
script | Script execution |
ssh | SSH access |
system | System events (startup, shutdown) |
wireless | Wireless events |
wireguard | WireGuard VPN events |
Topic Exclusion
Section titled âTopic ExclusionâUse ! to exclude topics:
/system logging add action=remote topics=info,!firewallThis logs all info messages except those also tagged firewall.
Syslog Facility Reference
Section titled âSyslog Facility Referenceâ| Facility | Typical Use |
|---|---|
daemon | Default; general system daemons |
local0 - local7 | Custom applications; use for multi-router identification |
auth | Authentication events |
syslog | Syslog-related messages |
user | User-level messages |
Related Topics
Section titled âRelated TopicsâFirewall Logging
Section titled âFirewall Loggingâ- Firewall Basics - firewall rules with logging actions
- NAT Masquerade - NAT with logging
System Integration
Section titled âSystem Integrationâ- System Backup - include logs in backups
- Scheduler - schedule log rotation scripts
- SNMP - SNMP traps complement logging
Security Monitoring
Section titled âSecurity Monitoringâ- User Management - audit user logins
- SSH Configuration - log SSH access
Reference
Section titled âReferenceâ- MikroTik Log Documentation
- Syslog with Elasticsearch
- Version changes:
- v7.20: Added
/system logging action clearcommand - v7.19: Added VRF support for remote logging
- v7.18: Added CEF format, millisecond timestamps, ISO8601 time format
- v7.20: Added
Key Properties Reference
Section titled âKey Properties ReferenceâLogging Action Properties
Section titled âLogging Action Propertiesâ| Property | Type | Default | Description |
|---|---|---|---|
name | string | - | Action identifier (required) |
target | memory/disk/echo/remote/email | memory | Destination type |
memory-lines | 1-65535 | 1000 | Lines stored in RAM buffer (memory target) |
disk-file-name | string | log | Base filename (disk target) |
disk-lines-per-file | 1-65535 | 100 | Lines per file before rotation |
disk-file-count | 1-65535 | 2 | Number of rotating files |
remote | IP[:port] | 0.0.0.0:514 | Syslog server address |
remote-port | integer | 514 | Syslog server port |
remote-protocol | tcp/udp | udp | Transport protocol |
remote-log-format | cef/default/syslog | default | Output format |
syslog-facility | enum | daemon | RFC 3164 facility |
syslog-time-format | bsd-syslog/iso8601 | bsd-syslog | Timestamp format |
vrf | name | main | VRF for remote logging (v7.19+) |
email-to | string | - | Recipient address (email target) |
Logging Rule Properties
Section titled âLogging Rule Propertiesâ| Property | Type | Description |
|---|---|---|
action | string | Action name for matching logs |
topics | string | Comma-separated topic list (ANDed) |
prefix | string | Text prepended to log messages |