如何通过rabbitmqctl命令在RabbitMQ中设置lager.error_logger_hwm

How to set lager.error_logger_hwm in RabbitMQ by rabbitmqctl command

这个 不适合我的情况 运行 rabbitmq(RabbitMQ 3.7.10 on Erlang 20.2.2 -- Ubuntu 16.04 ) 通过 docker 容器。

我可以在主机目录中添加 advanced.config,并更新 config.json 以生成 /var/lib/rabbitmq/config/generated/rabbitmq.config 重启后自动.

root@*-pc:/etc/kolla/rabbitmq# cat advanced.config 
[
    {lager, [
        {error_logger_hwm, 4000}
    ]}
].

root@*-pc:/etc/kolla/rabbitmq# cat config.json 
{
    "command": "/usr/sbin/rabbitmq-server",
    "config_files": [
        {
            "source": "/var/lib/kolla/config_files/advanced.config",
            "dest": "/etc/rabbitmq/advanced.config",
            "owner": "rabbitmq",
            "perm": "0600"
        },
        {
            "source": "/var/lib/kolla/config_files/rabbitmq.conf",
            "dest": "/etc/rabbitmq/rabbitmq.conf",
            "owner": "rabbitmq",
            "perm": "0600"
        },
        ......

root@*-pc:/etc/kolla/rabbitmq# docker restart  rabbitmq 
rabbitmq
root@*-pc:/etc/kolla/rabbitmq# docker exec rabbitmq rabbitmqctl eval 'application:get_env(lager, error_logger_hwm).'
{ok,4000}

问题:

# docker exec rabbitmq rabbitmqctl eval '[lager:set_loghwm(error_logger_hwm, 4000)]'
Error (argument validation): "syntax error before: "
Arguments given:
    eval [lager:set_loghwm(error_logger_hwm, 4000)]

Usage:
rabbitmqctl [-n <node>] [-l] [-q] eval <expr>

好像也没有提高上限,不知道是什么意思参考自RabbitMQ lager_error_logger_h dropped messages.

# docker exec rabbitmq rabbitmqctl eval 'application:get_env(lager, error_logger_hwm).'
{ok,50}

# docker exec rabbitmq rabbitmqctl eval '[lager:set_loghwm(H, 4000) || H <- gen_event:which_handlers(lager_event)].'
[{last_loghwm,50},ok]

# docker exec rabbitmq rabbitmqctl eval 'application:get_env(lager, error_logger_hwm).'
{ok,50}

# docker exec rabbitmq rabbitmqctl eval '[lager:set_loghwm(H, 4000) || H <- gen_event:which_handlers(lager_event)].'
[{last_loghwm,4000},ok]

# docker exec rabbitmq rabbitmqctl eval 'application:get_env(lager, error_logger_hwm).'
{ok,50}

你可以试试

docker exec rabbitmq rabbitmqctl eval 'application:set_env(lager,error_logger_hwm,4000).' 

也许有用。 https://www.erlang.org/doc/man/application.html#set_env-2

lager:set_loghwm(error_logger_hwm, 4000)]

上面的代码不起作用,因为lager 应用程序没有启动并且无法调用lager 的函数。 https://hexdocs.pm/lager/lager.html#set_loghwm-2