I am sending a message to rabbitMQ, I want to read this message and log it into a file. How can I do this?
RabbitMQ Debian and RPM packages will set up logrotate to run weekly on files located in default /var/log/rabbitmq directory. Rotation configuration can be found in /etc/logrotate. d/rabbitmq-server.
The default location for RabbitMQ logs on Windows can be found here: Default Locations on Windows. rabbitmqctl commands can be collected using rabbitmqctl. bat, located in the rabbitmq_server-<version>\sbin directory.
In order to trace all the messages being exchanged on the RabbitMQ server you can use the firehose tracer.
You can activate/deactivate it with the commands:
rabbitmqctl trace_on
rabbitmqctl trace_off
Once activated, all the messages will be duplicated to the exchange amq.rabbitmq.trace
.
Just bind a queue to it and consume from there. You can find a working example in our RabbitMQ Cookbook.
It should also be possible to directly trace the messages to file by using the rabbitmq_tracing plugin, but I have never tried it actually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With