I think the best way is to use a configuration file. I tried the above methods, but they did not help me. I used the following configuration here and it worked:
{lager, [ {handlers, [ {lager_file_backend, [{file, "rabbit.log"}, {level, info}, {date, "$D0"}, {size, 10}, {count, 2} ]}]} ]},
You can find information on what date, size and quantity does in this link https://github.com/basho/lager
source share