[erlang-questions] error_logger not outputting anything

Chi Zhang elecpaoao@REDACTED
Mon Apr 18 05:05:07 CEST 2011


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



More information about the erlang-questions mailing list