rabbitmq-server icon indicating copy to clipboard operation
rabbitmq-server copied to clipboard

log.file.rotation.date syntax supports a limited number of options compared to Lager

Open sedhupathygit opened this issue 3 years ago • 5 comments
trafficstars

in config file the line log.file.rotation.date = $D0 is working fine whereas the $D12H30 or anything other than day is causing a failure to start service. I'm using rabbitmq-server=3.9.11-1 and erlang/bionic 1:24.1.7-1 and primary configuration file format.

The error log :

Application rabbit exited with reason: {{cannot_log_to_file,unknown,{callback_crashed,{error,{case_clause,{0,[]}},[{rabbit_logger_std
,application_controller,"{application_start_failure,rabbit,{{cannot_log_to_file,unknown,{callback_crashed,{error,{case_clause,{0,[]}},[{rabbit_logger_std_h,pa
pplication_controller) ({application_start_failure,rabbit,{{cannot_log_to_file,unknown,{callback_crashed,{error,{case_clause,{0,[]}},[{rabbit_logger_std_h,par 

sedhupathygit avatar Dec 02 '21 10:12 sedhupathygit

parse_date_spec/1 misses clauses for $H:

parse_date_spec(false) ->
    false;
parse_date_spec("") ->
    false;
parse_date_spec([$$,$D | DateSpec]) ->
    io:format(standard_error, "parse_date_spec: ~p (hour)~n", [DateSpec]),
    parse_hour(DateSpec, #{every=>day,
                           hour=>0});
parse_date_spec([$$,$W | DateSpec]) ->
    io:format(standard_error, "parse_date_spec: ~p (week)~n", [DateSpec]),
    parse_day_of_week(DateSpec, #{every=>week,
                                  hour=>0});
parse_date_spec([$$,$M | DateSpec]) ->
    io:format(standard_error, "parse_date_spec: ~p (month)~n", [DateSpec]),
    parse_day_of_month(DateSpec, #{every=>month,
                                   hour=>0});
parse_date_spec(DateSpec) ->
    io:format(standard_error, "parse_date_spec: ~p (error)~n", [DateSpec]),
    error.

@dumbbell is there a reason for that?

The function logs to standard error, which for this setting doesn't seem to be necessary.

michaelklishin avatar Dec 02 '21 11:12 michaelklishin

The following examples from the doc fail with various function clauses. It's not specific to Debian:

log.file.rotation.date = $W5D16
log.file.rotation.date = $H00

michaelklishin avatar Dec 02 '21 12:12 michaelklishin

From the looks of some portions of the parser and docs, my guess is that the format documentation predates the standard OTP logger transition. All those values were supported by Lager but the current implementation is a lot more limited.

michaelklishin avatar Dec 02 '21 12:12 michaelklishin

https://rabbitmq.com/logging.html#log-rotation no longer documents what we do not support. On Linux, logrotate should be an easily accessible option which would always be superior to anything that built-in rotation ever provides. So use that.

michaelklishin avatar Dec 02 '21 12:12 michaelklishin

https://groups.google.com/g/rabbitmq-users/c/lxcH6Nk17as

lukebakken avatar Dec 02 '21 14:12 lukebakken

Fixed by #3835

lukebakken avatar Feb 24 '23 15:02 lukebakken