Question

I currently trying to setup otp logging in my app as documentation recommends to use it.

I have following startup line:

erl -pa ebin edit deps/*/ebin -boot start_sasl \
            -detached \
            -sasl sasl_error_logger "{file, \"priv/log/app.log\"}" \
            -sasl errlog_type all \
            -sname $APP_NAME \
            -s $APP_NAME

But when i say in my app something like error_logger:error_report("!!!!") or error_logger:error_msg("!!!!"), then nothing is printed in log file, what i'm doing wrong ?

Was it helpful?

Solution

The problem is very simple. SASL only logs PROGRESS, CRASH and SUPERVISOR reports (or so the documentation says). You are sending something which is an ERROR report which it doesn't log. If you create some crash in a process that is SASL-enabled, say

proc_lib:spawn(fun() -> exit(argh) end).

Then that report should come up in your log. I think the mf logger takes everything but I might be wrong. It also requires the rb tool to read the log files in question. A good alternative for a real application is to use the lager application written by the fine guys at Basho technologies. It provides a more syslog-like interface and it also handles SASL error log types too. In addition it won't destroy your server if you try to log a very large process state - which the default SASL loggers will.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top