2
votes
  • There is a gen_server that keeps some sensible information in it's state (password and so on)

  • Lagger is enabled,

    So in case of crash gen_server's state is dump to the crash log like:

     yyyy-mm-dd hh:mm:ss =ERROR REPORT====
    ** Generic server XXX terminating 
    ** Last message in was ...
    ** When Server state == {state, ...}
    ** Reason for termination ==

As a result sensible information is written to the log file.

Are there any way to prevent state of the gen_server to be written into the log files/crash dumps?

2

2 Answers

3
votes

You could implement the optional format_status callback function. That means that whenever the gen_server crashes, you get the chance to format the state data to your liking before it gets logged, for example by removing sensitive information.

0
votes

You can add this into your app.config: {lager, [{error_logger_redirect, false}]} to prevent lager from redirecting error logs. You should also try to catch error (that causes gen_server to crash) and handle it in some graceful way. Our you can keep passwords salted and just let it crash.