RabbitMQ开启消息跟踪日志(trace)

Trace 是Rabbitmq用于记录每一次发送的消息,方便使用Rabbitmq的开发者调试、排错。

1、启动Tracing插件

在RabbitMQ中默认是关闭的,需手动开启。此处rabbitMQ是使用docker部署的

## 进入rabbitMq中
docker exec -it rabbitmq1 bash
## 启动日志插件
rabbitmq-plugins enable rabbitmq_tracing
## 开启rabbitmq的tracing插件
rabbitmqctl trace_on

开启了插件后,无需重启,rabbitMq管理界面就会出现Tracing项,可新建追踪。

RabbitMQ开启消息跟踪日志(trace)_第1张图片
添加跟踪:
RabbitMQ开启消息跟踪日志(trace)_第2张图片
RabbitMQ开启消息跟踪日志(trace)_第3张图片

跟踪日志:

===============================================================================
2023-10-08 8:59:03:528: Message published

Node:         rabbit@host-01
Connection:   192.168.49.2:51303 -> 192.168.49.9:5672
Virtual host: /
User:         admin
Channel:      1
Exchange:     demoDirectExchange
Routing keys: [<<"demoDirectRouting">>]
Routed queues: [<<"demoDirectQueue">>]
Properties:   [{<<"priority">>,signedint,0},
               {<<"delivery_mode">>,signedint,2},
               {<<"headers">>,table,[]},
               {<<"content_type">>,longstr,
                <<"application/x-java-serialized-object">>}]
Payload: 
’

关闭跟踪:

# 查看打开的插件 
rabbitmq-plugins list
# 关闭trace功能
rabbitmqctl trace_off
# 停止tracing
rabbitmq-plugins disable rabbitmq_tracing

你可能感兴趣的:(运维,rabbitmq,分布式)