erlangerlang-otp

Erlang OTP 21 How to disable logger console output


According to erlang documentation is is possibe to configure logger for file only:

from Erlang Documentation:

Modify the default handler to print to a file instead of standard_io:

[{kernel,
[{logger,
  [{handler, default, logger_std_h,  % {handler, HandlerId, Module,Config}
    #{config => #{file => "log/erlang.log"}}}
]}]}].

My config file looks like:

 [{kernel,[
  {logger_level, error},
  {logger,
    [{handler, default, logger_std_h,
      #{config => #{file => "log/erlang.log"}}}
    ]
   }
  ]}].

i.o. exactly as in the documentation. with log level set to error

When I stat application using reabar3 shell following printed into console:

===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases (http://www.rebar3.org/docs/releases)
2019-04-10T15:14:33.363287+02:00 info: application: syntax_tools, started_at: 'node@x201'
2019-04-10T15:14:33.371897+02:00 info: application: compiler, started_at: 'node@x201'
2019-04-10T15:14:33.379962+02:00 info: supervisor: {local,gr_sup}, started: [{pid,<0.1181.0>},{id,gr_counter_sup},{mfargs,{gr_counter_sup,start_link,[]}},{restart_type,permanent},{shutdown,5000},{child_type,supervisor}]
2019-04-10T15:14:33.382379+02:00 info: supervisor: {local,gr_sup}, started: [{pid,<0.1182.0>},{id,gr_param_sup},{mfargs,{gr_param_sup,start_link,[]}},{restart_type,permanent},{shutdown,5000},{child_type,supervisor}]

So, OTP progress messages are not redirected to the file, but still printed to the console and file erlang.log is empty.

How to disable console output and redirect all messages to the file?

P.S. Erlang version:

Erlang/OTP 21 [erts-10.3.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Solution

  • After fighting for a while I found a problem:

    should be changed to:

    #{config => #{ type => {file => "log/erlang.log"}}}}

     [{kernel,
     [{logger,
      [{handler, default, logger_std_h,  % {handler, HandlerId, Module,Config}
       #{config => #{ type => {file => "log/erlang.log"}}}}
    ]}]}].
    

    Here: Complete example of logger configuration file