Unexpected stdout on releases

I have a release started via CI script: nohup <release-version> foreground > std_out.txt 2> std_err.txt &

My default logger is disabled and other loggers write to files. I redirected stdout just in case anything writes to it. However, I keep getting logs duplicated in log files and in std_out.txt.

When I run the release locally with rebar3 shell I don’t get this behavior. Why logs are redirected to stdout when running as a release?

In a release, the default logging configuration might be set up to log to both a file and the console (stdout). Even though you’ve disabled the default logger and redirected stdout to std_out.txt, it seems like another logger is still writing to stdout, causing the duplication. In a release, the default logging configuration might be set up to log to both a file and the console (stdout). Even though you’ve disabled the default logger and redirected stdout to std_out.txt, it seems like another logger is still writing to stdout, causing the duplication. Are you use lager or logger? In any case, you need to take a look to sys.config and double check the logging section - it can be that there provided some additional configuration part which need to disable or remove at all, or just a change a log level.

Logger with logger_std_h handler.

Configurations are the same, I checked that several times, except for file paths which are relative in dev env and absolute in prod env.

I disabled the default handler by putting {handler, default, undefined} into kernels logger config. Other handler work correctly and write to their files as they should. I even tried calling logger:handler_config(default) and it says that the handler doesn’t exists.

So, the problem is simple handler is (somehow) present in the release.

Reason is probably that rebar3 when running a release somewhere (didn’t exactly find where) calls logger:reconfigure/0 which causes simple handler to be added to the handlers. This can be prevented by setting kernels env var error_logger (which is undocumented) to silent. This will cause simple handler to be removed after reconfigure.

If I got it correctly, simple handler is added only not to loose logs during reconfiguration, I’d expect it to be removed after that by default…

Edit: issue opened