Logging to JSON in advanced/old config format

133 views
Skip to first unread message

Rui Santos

unread,
Jul 31, 2023, 1:11:33 PM7/31/23
to rabbitmq-users
Hello all,

I'm trying to configure JSON formatter in RabbitMQ. This is what I've inserted to /etc/rabbitmq/rabbitmq.config:
...
{rabbit, [
...
{log, [
{file, [{formatter,json}]}
]}
...

And with this config I'm getting the following error:
Application rabbit exited with reason: {{case_clause,{error,{invalid_formatter,json}}},{rabbit,start,[normal,[]]}}

I've tried reading trough the documentation and couldn't advance any further. I guess I may be doing something wrong. Could I please get some help on the right syntax on how to configure it?

Don't know if it's related, but I also consulted the schema mapping here:
and if you search for "{mapping, "log.file.formatter",",
you'll notice that it maps to "rabbit.log.file.formatter", but there's also numerous other mappings that will map to this one. Is it supposed to be like this?

Versions used:
- RabbitMQ 3.12.2 and 3.11.16
- Erlang 25.3.2.4 and 25.3.2 respectively

Thank you all for any help!

Regards,
Rui


Luke Bakken

unread,
Jul 31, 2023, 2:21:27 PM7/31/23
to rabbitmq-users
Hello,

You should be using the rabbitmq.conf file.

If you have settings that require the old-style configuration, put them in /etc/rabbitmq/advanced.config

Thanks,
Luke

Rui Santos

unread,
Aug 1, 2023, 11:11:30 AM8/1/23
to rabbitmq-users
Hi Luke,

Thank you for your reply. Unfortunately using those files is not an option due to the automation module being used, which is puppet.
However, you've made me go in the right direction. Just writing here, so others may benefit.

I've changed the file names manually namely:
- renamed rabbtimq.config to advanced.config
- created rabbitmq.conf with "log.file.formatter = json"
Then I restarted rabbitmq-server, which started to export the log in JSON.
Then with "rabbitmq-diagnostics environment" I was able to extract the "log" combination to use.

Just for reference "{log, [{file, [{formatter, {rabbit_logger_json_fmt,{}}}]}]}" will start json logging with the default values.

Thank you again Luke!

Regards,
Rui
Reply all
Reply to author
Forward
0 new messages