[erlang-questions] Erlang 21 Logger Configuration

Siri Hansen erlangsiri@REDACTED
Tue Mar 19 13:58:01 CET 2019


Hi Steve,

I'm sorry to say that there is a bit left to do in the logger_disk_log_h
handler. The error message you see actually comes from disk_log, and the
handler is not implemented to take care of that. Also, for simplicity (due
to lack of time) we decided to keep the max_no_bytes and max_no_files
read-only in this handler, which means that you can not changes these
options during run-time either :(

It seems you are running OTP 21.3, so if it's an option for you, you may
try the new rotation mechanism which is added to the logger_std_h handler
in that release. It has a rotation scheme that does not rely on any .idx or
.siz files. The log current log is always the one with the configured name,
and the rotated archives have .0, .1, ... extensions. And with this handler
you may change the max_no_files and max_no_bytes as you wish during
run-time or when re-opening an existing log file.

Kind Regards
/siri

Den tir. 19. mar. 2019 kl. 11:56 skrev Steve Strong <steve@REDACTED>:

> Hi All,
>
> Quick question regarding the handling of configuration changes for the
> disk_log hander in the new Logger framework, and specifically how it
> handles max_no_bytes.
>
> Given a clean directory, I can do the following:
>
> > erl
> Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:12:12] [ds:12:12:10]
> [async-threads:1] [hipe]
>
> Eshell V10.3  (abort with ^G)
> 1> logger:add_handler(disk_log, logger_disk_log_h, #{config => #{file =>
> "log/debug.log", type => wrap, max_no_files => 10, max_no_bytes => 10000},
> level => all}).
> ok
> 2>q().
>
> That creates me a log folder with a debug.log.1, debug.log.idx and
> debug.log.siz.  If I then start a new shell and try to create the handler
> but with a different max_no_bytes, I get the following:
>
> > erl
> Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:12:12] [ds:12:12:10]
> [async-threads:1] [hipe]
>
> Eshell V10.3  (abort with ^G)
> 1> logger:add_handler(disk_log, logger_disk_log_h, #{config => #{file =>
> "log/debug.log", type => wrap, max_no_files => 10, max_no_bytes => 15000},
> level => all}).
> {error,{handler_not_added,{size_mismatch,{10000,10},
>                                          {15000,10}}}}
> 2> q().
>
> Due to the change in the max_no_bytes parameter, the handler fails to
> start.  What is the recommended way to deal with adjusting config value
> such as this, particularly for handlers that may be added / removed
> dynamically?  Right now, we are needing to archive the entire log directory
> prior to changing values, which is a real pain.
>
>
> Cheers,
>
> Steve
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190319/a9c55964/attachment.htm>


More information about the erlang-questions mailing list