Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best way to rotate rabbitmq log files

My rabbit logs are getting very large and I am wondering if there is a better way to control the rotation. I'd like the logs to rotate based on size, and to keep at most ten logs at a time. The best I've found so far is that you can turn off logging by putting SERVER_START_ARGS="-kernel error_logger silent" into the rabbitmq.conf file. Is there a better way? I'd like to avoid using a crontab for this.

like image 682
Bacon Avatar asked Jun 13 '11 17:06

Bacon


4 Answers

The best choice is put the log rotate logical inside your rabbitmq.conf file like below:

{log, [
        {file, [{file, "/var/log/rabbitmq/rabbitmq.log"}, %% log.file
                {level, info},        %% log.file.info
                {date, "$D0"},           %% log.file.rotation.date
                {size, 1024},            %% log.file.rotation.size
                {count, 15}            %% log.file.rotation.count
                ]}
    ]},
like image 135
Rodrigo Andrade Avatar answered Sep 17 '22 07:09

Rodrigo Andrade


I think the best way is to use a config file. I tried above ways but they didn't work for me. I used the following configuration from here and it worked:

  {lager, [

    {handlers, [
      {lager_file_backend, [{file, "rabbit.log"},
                            {level, info},
                            {date, "$D0"},
                            {size, 10},
                            {count, 2}
    ]}]}
    ]},

You can find info on what does date, size and count do in this link https://github.com/basho/lager

like image 41
Lokesh Avatar answered Sep 20 '22 07:09

Lokesh


You can use the command .

rabbitmqctl rotate_logs

Its working for me. Read more from the http://www.rabbitmq.com/configure.html

Hope it will help you.

like image 42
JDGuide Avatar answered Sep 21 '22 07:09

JDGuide


The best way to do this is to upgrade to RabbitMQ 2.4.1. A lot of people are still running very old and obsolete RabbitMQ software that has problems with large persister logs. Newer versions handle this much better, and they also have a management plugin (web accessible) and much faster message routing.

Ideally you would upgrade to Erlang R14B02 first, then upgrade RabbitMQ.

Skip Erlang R14B03 if you are going to compile RabbitMQ from source.

like image 41
Michael Dillon Avatar answered Sep 21 '22 07:09

Michael Dillon