[erlang-questions] logging with email output

Adam Duston <>
Thu Nov 20 23:21:21 CET 2008


Thanks very much for the great responses, guys. I will put together
your advice and install a handler in error_logger that messages an
email-generating process.

Ulf, you are really awesome for explaining this stuff and providing
the note about AXD 301.

This is a great list. I'm happy I joined it; so far I've been typing
my Erlang code in isolation!

Thanks again,
Adam


On Thu, Nov 20, 2008 at 4:14 PM, Ulf Wiger <> wrote:
> You can install a handler in error_logger.
>
> http://www.erlang.org/doc/man/error_logger.html
>
> I would suggest that your handler sends a message to a
> process that in its turn generates the email. For one thing,
> event handlers should do as little as possible, since they are
> called sequentially in the error_logger process, and you probably
> also want to be able to aggregate crash reports if you get many
> at the same time.
>
> How to send the actual email depends on what system you're
> running on. With a working sendmail daemon, it's easy enough
> to just generate an email and use os:cmd().
>
> If your mail problem is more complex than that, perhaps erlmail
> has a solution. It seems to have IMAP, SMTP and POP clients,
> although I haven't tried it.
>
> http://code.google.com/p/erlmail/
>
>
> BTW, you may want to install a supervised event handler.
> It can be pretty annoying if there's an exception in the handler
> code, and the handler is quietly removed.
>
> For that, you use gen_event:add_sup_handler/3
>
> http://www.erlang.org/doc/man/gen_event.html
>
> It's not written in the ref manual, but the way to do it
> is to have a supervised process that installs the handler
> on startup, and dies if it receives a gen_event_EXIT message.
> This way, you get the same supervision strategy for your
> handler as for processes.
>
> BR,
> Ulf W
>
> 2008/11/20 Adam Duston <>:
>> In my Java application, I can use an email logging target with log4j
>> and then, when an exception occurs, an email is politely delivered to
>> my inbox. In my Erlang app, I'm logging info and errors using
>> error_logger. I would like to be notified by email when one of my
>> gen_servers trips badly enough to shutdown and get restarted by the
>> supervisor. What is the idiomatic way to do this?
>>
>> Thanks,
>> Adam
>>
>> --
>> Founder, 8 Planes
>> 
>> Skype: aduston
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>



-- 
Founder, 8 Planes

Skype: aduston



More information about the erlang-questions mailing list