1

I have a Python script that executes Redis commands via redis-py. How can I print the commands being executed when the script runs for debugging purposes? I have access to both the code and the Redis server.

1

1 Answer 1

4

You can use the Monitor command.

All you have to do is open the redis-cli and call MONITOR, and then it will log every command sent to Redis.

$ redis-cli 
127.0.0.1:6379> MONITOR
OK
1617778908.016538 [0 127.0.0.1:38138] "set" "foo" "bar"
Sign up to request clarification or add additional context in comments.

1 Comment

Great solution! Might be worth adding that you don't actually need to "enter" the CLI, you can start monitoring from outside if you want to redirect the output to a file or process it with awk or similar, e.g. redis-cli MONITOR | awk '...' or like redis-cli MONITOR > redis.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.