Send email or Telegram msg on log error

Hi all,

i would like to get an email notification every time there’s an error in logs, without needing to login to Umbraco backend. Or get telegram/whatsapp message for example.

Would that require switching to some external logging provider and then setup some workflow and alerting there, or I can do something simpler and just add config/code simple plugin that does that?

Btw, Umbraco is v13, there are some breaking changes preventing me from upgrade (grrrr:( )

cheers

Hi @hudo

You would need to implement your own ILogEventSink which is a Serilog interface so you can intercept writes to the log and then filter and output to your own destination of choice.

There is an example here you can follow:

Just be careful as this will get hit for every log entry, so you may end up spamming yourself and consuming API credit for third party APIs. You may want to include some rate limiting to ensure that duplicate messages are only sent every X minutes.

We’ve written a custom database sink so log entries get written and persisted to the database as our servers are torn down and rebuilt regularly so the file system logging is not persisted indefinitely.

Justin

This will work for Umbraco 13 and later if you upgrade.

Great, thanks, I can add my own sink and just push errors to telegram/whatsapp, should be easy enough!
Thanks.

1 Like