Hi Chi Zhang!<div><br></div><div>Can you see if there are any outputs from the error_logger from any other handlers?</div><div><br></div><div>Can you check if your handler is still known to the error_logger:</div><div><br>
</div><div>gen_event:which_handlers(error_logger).</div><div><br></div><div>You could also check the state of the error logger:</div><div><br></div><div>sys:get_status(error_logger) - which will (amongst others) show all handlers and their State variable.</div>
<div><br></div><div>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.</div><div><br></div><div>I hope this gives some indication of what might be the problem.</div>
<div><br></div><div>Regards</div><div>/siri@otp</div><div><br></div><div><br></div><div><br><div class="gmail_quote">2011/4/18 Chi Zhang <span dir="ltr"><<a href="mailto:elecpaoao@gmail.com">elecpaoao@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi<br>
<br>
I added an event handler to redirect error_logger reports to syslog.<br>
The handler looks like this:<br>
<br>
handle_event({info_msg, _Gleader, {_Pid, Format, Data}},<br>
#state{info_logger=Logger}=State) -><br>
syslog_write("I", Logger, Format, Data),<br>
{ok, State};<br>
handle_event({error, _Gleader, {_Pid, Format, Data}},<br>
#state{error_logger=Logger}=State) -><br>
syslog_write("E", Logger, Format, Data),<br>
{ok, State};<br>
handle_event(_Event, State) -><br>
{ok, State}.<br>
<br>
syslog_write(Prefix, Facility, Format, Data) -><br>
Cmd = try<br>
Message = lists:flatten(io_lib:format(Format, Data)),<br>
lists:flatten(io_lib:format("logger -t essmsd -p<br>
~s.Debug \'<~s> ~s\'",<br>
[Facility, Prefix, Message]))<br>
catch<br>
_:_ -><br>
lists:flatten(io_lib:format("logger -t essmsd -p<br>
~s.Debug \'~p\'",<br>
[Facility, [Prefix,<br>
Format, Data]]))<br>
end,<br>
os:cmd(Cmd).<br>
<br>
I used logger command to write to syslog files. It works at first, but<br>
after running for one or two days,<br>
the error_logger stopped working. It outputs nothing (when I invoke<br>
error_logger:info_msg("test") on the console,<br>
it only returns an ok) no matter what the input, neither to the log<br>
file, nor to the console.<br>
<br>
I tried to put trace on the function syslog_write and<br>
error:logger:info_msg and it gave me the following result:<br>
<br>
(essmsd@xx.xx.xx.xx)11> dbg:tracer(), dbg:p(all, c),<br>
dbg:tpl(error_logger, info_msg, x).<br>
{ok,[{matched,'essmsd@xx.xx.xx.xx',2},{saved,x}]}<br>
<br>
(essmsd@xx.xx.xx.xx)12> error_logger:info_msg("xx").<br>
ok<br>
(<0.1735.0>) call error_logger:info_msg("xx")<br>
<br>
(essmsd@xx.xx.xx.xx)13><br>
(<0.1735.0>) call error_logger:info_msg("xx",[])<br>
(<0.1735.0>) returned from error_logger:info_msg/2 -> ok<br>
(<0.1735.0>) returned from error_logger:info_msg/1 -> ok<br>
<br>
Which means the error_logger:info_msg is being called, but it never<br>
output anything but returned an ok!<br>
<br>
--<br>
Sincerely Yours,<br>
Chi Zhang<br>
<br>
<a href="mailto:elecpaoao@gmail.com">elecpaoao@gmail.com</a><br>
College of Computer Science and Technology, Zhejiang University<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>