Logging Spanning Tree info on switches running RouterOS?

I think the title is fairly clear here, but I’ll explain further.

I have a bunch of switches running RouterOS (v7.x, mostly 7.12 but some might be more up-to-date).

I am trying to log what I would consider basic “info”-level events from Spanning Tree - e.g. STP Root changes, or if the local switch isn’t STP Root, which port is the root port, that kind of thing.

The default logging configuration (critical / error / warning / info for all Topics) does not seem to capture anything about Spanning Tree. There is a separate “Topic” in Logging called “stp”, so I tried adding a rule to just log that single topic… and I’m still not getting any information from it, even after an event that caused the STP Root to change (verified by looking at the Status tab of the Bridge entry itself in Winbox).

Please note, I do not want full “debug-level” info about STP, since I expect that would be a ton of log info and it’s more than I care about right now. I’m just looking for pretty standard switch-level details that help with network optimization / dealing with layer 2 loops / etc. As an example, I can’t even find a way to show number of BPDUs received on an interface, or details about topology changes.

Is this a bug? Is Spanning Tree supposed to be logging info in the “stp” Topic, but it just isn’t for some reason?

http://forum.mikrotik.com/t/stp-logging-how-to/173399/1

Please re-read my original post. I already added a dedicated logging rule just for Topic = stp, and that did not work, that’s why I’m posting here.

Here’s /system/logging/export verbose - the “Action = librenms” is a remote/syslog target and I omitted the details from that because I don’t think they’re important. I’m not even getting STP info displayed in the memory buffer. There is not anything else filling the buffer rapidly - there is simply no output from STP. I made a change that caused the root port & root bridge to change, but nothing was logged.

/system logging
set 0 action=memory disabled=no prefix="" topics=info
set 1 action=memory disabled=no prefix="" topics=error
set 2 action=memory disabled=no prefix="" topics=warning
set 3 action=echo disabled=no prefix="" topics=critical
add action=librenms disabled=no prefix="" topics=info,!firewall,!dhcp
add action=librenms disabled=no prefix="" topics=error
add action=librenms disabled=no prefix="" topics=warning
add action=librenms disabled=no prefix="" topics=critical
add action=memory disabled=no prefix="" topics=stp
add action=memory disabled=no prefix="" topics=critical
add action=librenms disabled=no prefix="" topics=stp

an example of what i got from stp logging


 01-21 04:00:31 interface,info sfp-6 link up (speed 10G, full duplex)
 01-21 04:00:31 interface,info sfp-8 link up (speed 10G, full duplex)
 01-21 04:00:31 bridge,stp sfp-6:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-8:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-8:0 learning
 01-21 04:00:31 bridge,stp sfp-8:0 forwarding
 01-21 04:00:31 interface,info sfp-16 link up (speed 10G, full duplex)
 01-21 04:00:31 interface,info sfp-1 link up (speed 10G, full duplex)
 01-21 04:00:31 interface,info sfp-3 link up (speed 10G, full duplex)
 01-21 04:00:31 interface,info sfp-5 link up (speed 10G, full duplex)
 01-21 04:00:31 bridge,stp sfp-16:0 becomes Designated
 01-21 04:00:31 interface,info sfp-12 link up (speed 1G, full duplex)
 01-21 04:00:31 interface,info sfp-13 link up (speed 1G, full duplex)
 01-21 04:00:31 interface,info sfp-14 link up (speed 1G, full duplex)
 01-21 04:00:31 bridge,stp sfp-1:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-1:0 learning
 01-21 04:00:31 bridge,stp sfp-1:0 forwarding
 01-21 04:00:31 bridge,stp sfp-3:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-3:0 learning
 01-21 04:00:31 bridge,stp sfp-3:0 forwarding
 01-21 04:00:31 bridge,stp sfp-5:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-5:0 learning
 01-21 04:00:31 bridge,stp sfp-5:0 forwarding
 01-21 04:00:31 bridge,stp sfp-12:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-12:0 learning
 01-21 04:00:31 bridge,stp sfp-12:0 forwarding
 01-21 04:00:31 bridge,stp sfp-13:0 becomes Designated
 01-21 04:00:31 bridge,stp sfp-14:0 becomes Designated
 01-21 04:00:32 bridge,stp sfp-16:0 learning
 01-21 04:00:32 bridge,stp sfp-16:0 forwarding
 01-21 04:00:32 bridge,stp sfp-16:0 TCHANGE start
 01-21 04:00:33 bridge,stp sfp-14:0 learning
 01-21 04:00:33 bridge,stp sfp-14:0 forwarding
 01-21 04:00:33 bridge,stp sfp-13:0 learning
 01-21 04:00:33 bridge,stp sfp-13:0 forwarding
 01-21 04:00:33 bridge,stp sfp-6:0 learning
 01-21 04:00:33 bridge,stp sfp-6:0 forwarding
 01-21 04:00:35 bridge,stp sfp-16:0 TCHANGE over
 01-21 04:00:37 interface,info sfp-14 link down
 01-21 04:00:42 interface,info sfp-14 link up (speed 1G, full duplex)
 01-21 04:00:42 bridge,stp sfp-14:0 becomes Designated
 01-21 04:00:42 bridge,stp sfp-14:0 learning
 01-21 04:00:42 bridge,stp sfp-14:0 forwarding
 01-21 04:00:42 bridge,stp sfp-14:0 TCHANGE start
 01-21 04:00:42 bridge,stp sfp-16:0 TCHANGE start
 01-21 04:00:44 bridge,stp sfp-14:0 TCHANGE over
 01-21 04:00:44 bridge,stp sfp-16:0 TCHANGE over
 01-21 04:00:51 interface,info sfp-10 link up (speed 10G, full duplex)
 01-21 04:00:51 bridge,stp sfp-10:0 becomes Designated
 01-21 04:00:51 bridge,stp sfp-10:0 learning
 01-21 04:00:51 bridge,stp sfp-10:0 forwarding
 01-21 04:00:51 bridge,stp sfp-10:0 TCHANGE start
 01-21 04:00:51 bridge,stp sfp-16:0 TCHANGE start
 01-21 04:00:51 bridge,stp sfp-14:0 TCHANGE start
 01-21 04:00:53 bridge,stp sfp-14:0 TCHANGE over
 01-21 04:00:53 bridge,stp sfp-16:0 TCHANGE over
 01-21 04:00:53 bridge,stp sfp-10:0 TCHANGE over

only config needed was this


/system logging
add topics=stp

I see STP events only when interface changes state; unplug and replug same follows.

[admin@mtrb5009a] /> /system/logging/export terse
# 2025-01-21 17:32:30 by RouterOS 7.16.2
# software id = KWPA-GEH1
#
# model = RB5009UG+S+
# serial number = XXXXXXXXXXX
/system logging action add name=mempage target=memory
/system logging add action=mempage topics=stp
[admin@mtrb5009a] /> /log/print where topics~"stp"
 01-21 17:23:57 bridge,stp ether1:0 becomes Root
 01-21 17:23:57 bridge,stp ether1:1 becomes Root
 01-21 17:23:57 bridge,stp ether1:2 becomes Root
 01-21 17:24:05 bridge,stp sfp-sfpplus1:0 becomes Designated
 01-21 17:24:05 bridge,stp sfp-sfpplus1:1 becomes Designated
 01-21 17:24:05 bridge,stp sfp-sfpplus1:2 becomes Designated
 01-21 17:24:06 bridge,stp ether1:0 becomes Designated
 01-21 17:24:06 bridge,stp sfp-sfpplus1:0 becomes Root
 01-21 17:24:06 bridge,stp ether1:0 discarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:0 learning
 01-21 17:24:06 bridge,stp sfp-sfpplus1:0 forwarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:0 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:0 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:1 becomes Designated
 01-21 17:24:06 bridge,stp sfp-sfpplus1:1 becomes Root
 01-21 17:24:06 bridge,stp ether1:1 discarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:1 learning
 01-21 17:24:06 bridge,stp sfp-sfpplus1:1 forwarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:1 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:1 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:2 becomes Designated
 01-21 17:24:06 bridge,stp sfp-sfpplus1:2 becomes Root
 01-21 17:24:06 bridge,stp ether1:2 discarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:2 learning
 01-21 17:24:06 bridge,stp sfp-sfpplus1:2 forwarding
 01-21 17:24:06 bridge,stp sfp-sfpplus1:2 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:2 TCHANGE start
 01-21 17:24:06 bridge,stp ether1:0 learning
 01-21 17:24:06 bridge,stp ether1:1 learning
 01-21 17:24:06 bridge,stp ether1:2 learning
 01-21 17:24:06 bridge,stp ether1:0 forwarding
 01-21 17:24:06 bridge,stp ether1:1 forwarding
 01-21 17:24:06 bridge,stp ether1:2 forwarding
 01-21 17:24:08 bridge,stp ether1:0 TCHANGE over
 01-21 17:24:08 bridge,stp ether1:1 TCHANGE over
 01-21 17:24:08 bridge,stp ether1:2 TCHANGE over
 01-21 17:24:08 bridge,stp sfp-sfpplus1:0 TCHANGE over
 01-21 17:24:08 bridge,stp sfp-sfpplus1:1 TCHANGE over
 01-21 17:24:08 bridge,stp sfp-sfpplus1:2 TCHANGE over

Some “monitor” output follows:

[admin@mtrb5009a] > /interface/bridge/monitor [find] once without-paging
                    state: enabled
      current-mac-address: F4:1E:57:32:23:BD
              root-bridge: no
           root-bridge-id: 0x2000.D4:01:C3:99:D9:8E
  regional-root-bridge-id: 0x2000.D4:01:C3:99:D9:8E
           root-path-cost: 0
                root-port: sfp-sfpplus1
               port-count: 9
    designated-port-count: 1
        mst-config-digest: 762e142b2728011ce5970be25e82c279
             fast-forward: no

[admin@mtrb5009a] > /interface/bridge/msti/monitor [find] once without-paging
                      state: enabled                  enabled                  enabled
                 identifier: 1                        2                        0
        current-mac-address: F4:1E:57:32:23:BD        F4:1E:57:32:23:BD        F4:1E:57:32:23:BD
                root-bridge: no                       no                       no
    regional-root-bridge-id: 0x1001.74:4D:28:B7:12:51 0x1002.74:4D:28:B7:12:51 0x2000.D4:01:C3:99:D9:8E
             root-path-cost: 0                        0                        0
                  root-port: sfp-sfpplus1             sfp-sfpplus1             sfp-sfpplus1
                 port-count: 9                        9                        9
      designated-port-count: 1                        1                        1

I apologize, I am getting some info in the log, but as ConradPino mentioned - only when an interface physically changes state (down/up).

I tested by changing a VLAN filter on an upstream device (non-Mikrotik), which caused the switch I was looking at & logging to become STP Root, and there were no log messages indicating the change at all. I had to go look at the proper tab on the bridge in order to see that the local switch was the new Root.

I have to imagine there is more detail available somewhere, hopefully it is something that can be added in a future release?

Saw this is the 7.19 beta changelog, and was reminded of this post.

*) bridge - added new STP monitoring fields for bridge and ports (Tx/Rx BPDU, Tx/Rx TC, forward/discard transitions, last topology change, message-age, max-age, remaining-hops, bridge-id);