Log4Net is a powerful logging framework used by Umbraco. Beyond basic file logging, it can be configured to send email notifications when errors occur — invaluable for catching production issues early.
Add the following configuration to the xml > log4net section of /Config/log4net.config:
<root>
<priority value="Error"/>
<appender-ref ref="APPENDER_NAME" />
</root>
<appender name="APPENDER_NAME" type="log4net.Appender.SmtpAppender">
<to value="EMAIL_TO" />
<from value="EMAIL_FROM" />
<subject value="EMAIL_SUBJECT" />
<smtpHost value="SMTP_HOST_NAME" />
<port value="SMTP_PORT" />
<authentication value="Basic"/>
<userName value="SMTP_USERNAME" />
<password value="SMTP_PASSWORD" />
<enableSsl value="SMTP_ENABLE_SSL" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="ERROR"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />
</layout>
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="LOGGER_TO_MATCH" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
Configuration Parameters
| Placeholder | Description | Example |
|---|---|---|
APPENDER_NAME | Unique identifier for this appender | MySmtpAppender |
EMAIL_TO | Recipient email address | alerts@example.com |
EMAIL_FROM | Sender address | no-reply@example.com |
EMAIL_SUBJECT | Email subject line | Application Error |
SMTP_HOST_NAME | SMTP server hostname | email-smtp.eu-west-1.amazonaws.com |
SMTP_PORT | SMTP port | 25, 465, or 587 |
SMTP_USERNAME | SMTP authentication username | — |
SMTP_PASSWORD | SMTP authentication password | — |
SMTP_ENABLE_SSL | Enable SSL/TLS | true or false |
LOGGER_TO_MATCH | Fully qualified class name to filter on | My.Namespace.MyClass |
The DenyAllFilter at the end ensures only log events from the matched class trigger emails — without it, all ERROR level events in the application would be sent.