如何在 docker 中输出 mqtt 运行 的自定义日志
How to output custom logs of mqtt running in docker
我一直在使用 Mosquitto 的 docker 图像进行本地开发。它工作正常,但我想知道是否有任何方法可以在不更新源代码的情况下将自定义日志添加到如下所示的 docker-compose 输出中。例如,我想尝试向连接的客户端添加其他信息,例如正在发布的主题和消息。这不是生产的想法,只是我好奇的事情。
我的docker-compose.yml
:
version: '3'
services:
mqtt:
image: eclipse-mosquitto:latest
container_name: mqtt
volumes:
- ./docker/mosquitto.conf:/mosquitto/config/mosquitto.conf
ports:
- 1883:1883
只需编辑正在装载到容器中的 ./docker/mosquitto.conf
文件即可提高日志记录级别。
log_type
配置选项是您想要的,可接受值的详细信息可以在 man page
中找到
log_type types
Choose types of messages to log. Possible types
are: debug, error, warning,notice, information, subscribe, unsubscribe, websockets, none, all.
Defaults to error, warning, notice and information. This option may be
specified multiple times. Note that the debug type (used for decoding
incoming/outgoing network packets) is never logged in topics.
Reloaded on reload signal.
我一直在使用 Mosquitto 的 docker 图像进行本地开发。它工作正常,但我想知道是否有任何方法可以在不更新源代码的情况下将自定义日志添加到如下所示的 docker-compose 输出中。例如,我想尝试向连接的客户端添加其他信息,例如正在发布的主题和消息。这不是生产的想法,只是我好奇的事情。
我的docker-compose.yml
:
version: '3'
services:
mqtt:
image: eclipse-mosquitto:latest
container_name: mqtt
volumes:
- ./docker/mosquitto.conf:/mosquitto/config/mosquitto.conf
ports:
- 1883:1883
只需编辑正在装载到容器中的 ./docker/mosquitto.conf
文件即可提高日志记录级别。
log_type
配置选项是您想要的,可接受值的详细信息可以在 man page
log_type types
Choose types of messages to log. Possible types are: debug, error, warning,notice, information, subscribe, unsubscribe, websockets, none, all.
Defaults to error, warning, notice and information. This option may be specified multiple times. Note that the debug type (used for decoding incoming/outgoing network packets) is never logged in topics.
Reloaded on reload signal.