Gen_event: documentation @ https://www.erlang.org/doc/system/events

init(File) ->
    {ok, Fd} = file:open(File, read),
    {ok, Fd}.

should read

init(File) ->
    {ok, Fd} = file:open(File, write), % instead of read
    {ok, Fd}.

and, for the sake of completeness, please add

gen_event:add_handler(error_man, file_logger, ["file_logger.log"]).

addendum: The same applies to the documentation found at gen_event Behaviour — Erlang System Documentation v27.2.2

For things like that, you should open an issue at the OTP repo, or better still, submit a PR with corrections :wink:

1 Like