The default implementation of ILogger is Abp.Castle.Logging.Log4Net.Log4NetLogger.
I need to extend its functionality so when logging an exception it also sends an email.
What would be the best approach for this?
The Log4NetLogger class has no virtual methods. Should I copy the entire class and customize it as desired?
Thanks
4 Answer(s)
-
1
You can send mail directly using Log4Net. see:https://logging.apache.org/log4net/release/config-examples.html#smtpappender
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thanks. Indeed that seems like the easiest approach.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Tried the SmtpAppender and couldn't make it work. Enabled internal logging of log4net and found that the SmtpAppender is not available in .Net Core. The same issue as described here: smtpappender-missing-in-log4net-2-0-8-nuget
I'll go with custom Log4NetLogger approach another day with some more time.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
1
You can also change the log component, such as NLOG(https://github.com/NLog/NLog/wiki/Mail-target), which supports the net core very well.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)