Stan Wiechers
Stan Wiechers

Reputation: 2092

Logging behavior of rabbitmq docker container

I am using the rabbitmq:3.10 image locally on my mac. By default rabbitmq emits info logs to console which can lead to a good amount of logging noise.

According to the documentation configuration changes such as logging changes can be adjusted via an additional .conf file in a separate folder that is declared via the RABBITMQ_CONFIG_FILES environment variable.

FROM  rabbitmq:3.10

ENV RABBITMQ_CONFIG_FILES=/local/my-conf.d/
COPY ./config/ /local/my-conf.d/
RUN chown -r rabbitmq:rabbitmq /local/my-conf.d/

In my local conf folder I have the file 'disable_logging.conf' with the log level change.

log.console.level = error

I build the image that way

docker build -t rabbitmqlocal .

and run it that way

docker run rabbitmqlocal 

Whatever I do, I tried various .conf files, with or without chown rabbitmq always stops the boot process with Application syslog exited with reason: stopped in the logs

2022-09-26 12:41:03.377639+00:00 [notice] <0.44.0> Application syslog exited with reason: stopped
...
  Config file(s): /local/my-conf.d/disable_logging.conf

How do I change log level on a local rabbitmq docker container?

Upvotes: 2

Views: 4969

Answers (2)

Luke Bakken
Luke Bakken

Reputation: 9657

Please see a complete working example here:

https://github.com/lukebakken/stackoverflow-73854347

Dockerfile contents:

FROM  rabbitmq:3-management

RUN mkdir -p /etc/rabbitmq/conf.d
RUN chown -R rabbitmq:rabbitmq /etc/rabbitmq/conf.d
COPY 20-logging.conf /etc/rabbitmq/conf.d

EXPOSE 4369 5671 5672 15671 15672 15692 25672 35672-35682

20-logging.conf contents:

log.console = true
log.console.level = error
log.file.level = info

Upvotes: 5

Reda E.
Reda E.

Reputation: 878

Make sure to edit log-level in rabbitmq.conf https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbit/docs/rabbitmq.conf.example

...
## Log level for file logging
##
 log.file.level = info

For Mac, this file is under ${install_prefix}/etc/rabbitmq/rabbitmq.conf please see: https://www.rabbitmq.com/configure.html#config-location

Update

But since Docker image is built on top of ubuntu:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

I connected within the container and started the server:

Starting broker...2022-09-27 08:23:22.933866+00:00 [info] <0.223.0>
2022-09-27 08:23:22.933866+00:00 [info] <0.223.0>  node           : rabbit@76814e18acec
2022-09-27 08:23:22.933866+00:00 [info] <0.223.0>  home dir       : /var/lib/rabbitmq
2022-09-27 08:23:22.933866+00:00 [info] <0.223.0>  config file(s) : /etc/rabbitmq/conf.d/10-defaults.conf

So it is reading configuration from /etc/rabbitmq/conf.d/10-defaults.conf

You should copy your configuration to path above, re-build again and it should update your log level

Upvotes: 1

Related Questions