BMv2 Switch log

One obstacle in data plane programming is having access to the switch log to better understand what is happening inside the data plane to validate our P4 codes and change it if necessary. Using P4D this is easily achieved by analyzing the BMv2 log in real time.

By default, each switch will start storing the log of the BMv2 switch in the file /tmp/switch.log You can just access this file in real-time using the command:

docker exec -it <name> tail -f /tmp/switch.log

"docker exec -it": specifies that you want a container to execute a command

<name>: is the name of the switch, given at the creation of the node

"tail -f" : linux command that gets the last lines of a file and update it every time a change occurs

"/tmp/switch.log"

In the example presented in the previous tutorial, the command is:

docker exec -it sw1 tail -f /tmp/switch.log

Now the switch log is accessible in real-time You can add custom messages to your P4 code with the command:

log_msg("TEXT"); This way, you can search for specific keywords in the log.

Last updated