How To Configure Persistent Logging On Mikrotik RouterOS
By default a MikroTik router only keep logs in memory. This means that when the router reboots all the logging historical data is erased and lost. In a real world situation where router logs are needed during router troubleshooting and setup, loosing router logs can be disasterous. This tutorial aims to provide a guide on how to setup persistent logging on a Mikrotik Router by saving system logs to disk.
1) Desktop or laptop computer
2) Winbox utility
3) Internet connection (optional)
4) RouterOS admin access
Step One : Configure Persistent Logging Using Winbox
1)Connect your Routerboard to a power source, connect an RJ45 ethernet cable to ether2 and the ethernet port of your laptop / desktop
2) If your connection is successful Winbox will automatically detect all connected Routerboard devices as shown in the image, if you do not see your routerboard device try to click the refresh button under the neighbours tab or try to power cycle your routerboard.
3) Once you have logged in successfully browse to “SYSTEM > LOGGING”. On the “RULES” tab double click on each default rule. On the “LOG RULE” window that appears click on the “COPY” button to create a duplicate and adjust the Action dropdown to disk. Press the “OK” button to save the new rule.
4) Repeat step 3 until you have duplicated all 5 (critical, error, info, and warning) default logging rules. The image shows an example of this.
Step Two : Setup Log File Retention Settings
4)Browse to “SYSTEM > LOGGING”. Select the “ACTIONS” tab where you can configure the file size liit and number of log files to keep. For disk performance reasons 3000 lines per log file is recommended but you may specify more lines depending on your mikrotik router model.