[erlang-questions] error_logger not outputting anything

Siri Hansen erlangsiri@REDACTED
Mon Apr 18 09:46:49 CEST 2011


Hi Chi Zhang!

Can you see if there are any outputs from the error_logger from any other
handlers?

Can you check if your handler is still known to the error_logger:

gen_event:which_handlers(error_logger).

You could also check the state of the error logger:

sys:get_status(error_logger) - which will (amongst others) show all handlers
and their State variable.

If all seems ok -  you could try tracing you own module to see if your msg
for some reason ends up in the "catch all" clause of handle_event.

I hope this gives some indication of what might be the problem.

Regards
/siri@REDACTED



2011/4/18 Chi Zhang <elecpaoao@REDACTED>

> Hi
>
> I added an event handler to redirect error_logger reports to syslog.
> The handler looks like this:
>
> handle_event({info_msg, _Gleader, {_Pid, Format, Data}},
> #state{info_logger=Logger}=State) ->
>    syslog_write("I", Logger, Format, Data),
>    {ok, State};
> handle_event({error, _Gleader, {_Pid, Format, Data}},
> #state{error_logger=Logger}=State) ->
>    syslog_write("E", Logger, Format, Data),
>    {ok, State};
> handle_event(_Event, State) ->
>    {ok, State}.
>
> syslog_write(Prefix, Facility, Format, Data) ->
>    Cmd = try
>              Message = lists:flatten(io_lib:format(Format, Data)),
>              lists:flatten(io_lib:format("logger -t essmsd -p
> ~s.Debug \'<~s> ~s\'",
>                                           [Facility, Prefix, Message]))
>          catch
>              _:_ ->
>                  lists:flatten(io_lib:format("logger -t essmsd -p
> ~s.Debug \'~p\'",
>                                              [Facility, [Prefix,
> Format, Data]]))
>          end,
>    os:cmd(Cmd).
>
> I used logger command to write to syslog files. It works at first, but
> after running for one or two days,
> the error_logger stopped working. It outputs nothing (when I invoke
> error_logger:info_msg("test") on the console,
>  it only returns an ok) no matter what the input, neither to the log
> file, nor to the console.
>
> I tried to put trace on the function syslog_write and
> error:logger:info_msg and it gave me the following result:
>
> (essmsd@REDACTED)11> dbg:tracer(), dbg:p(all, c),
> dbg:tpl(error_logger, info_msg, x).
> {ok,[{matched,'essmsd@REDACTED',2},{saved,x}]}
>
> (essmsd@REDACTED)12> error_logger:info_msg("xx").
> ok
> (<0.1735.0>) call error_logger:info_msg("xx")
>
> (essmsd@REDACTED)13>
> (<0.1735.0>) call error_logger:info_msg("xx",[])
> (<0.1735.0>) returned from error_logger:info_msg/2 -> ok
> (<0.1735.0>) returned from error_logger:info_msg/1 -> ok
>
> Which means the error_logger:info_msg is being called, but it never
> output anything but returned an ok!
>
> --
> Sincerely Yours,
> Chi Zhang
>
> elecpaoao@REDACTED
> College of Computer Science and Technology, Zhejiang University
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110418/9771a0b6/attachment.htm>


More information about the erlang-questions mailing list