log4net.Ext.Mail
3.4.0-preview.1
dotnet add package log4net.Ext.Mail --version 3.4.0-preview.1
NuGet\Install-Package log4net.Ext.Mail -Version 3.4.0-preview.1
<PackageReference Include="log4net.Ext.Mail" Version="3.4.0-preview.1" />
<PackageVersion Include="log4net.Ext.Mail" Version="3.4.0-preview.1" />
<PackageReference Include="log4net.Ext.Mail" />
paket add log4net.Ext.Mail --version 3.4.0-preview.1
#r "nuget: log4net.Ext.Mail, 3.4.0-preview.1"
#:package log4net.Ext.Mail@3.4.0-preview.1
#addin nuget:?package=log4net.Ext.Mail&version=3.4.0-preview.1&prerelease
#tool nuget:?package=log4net.Ext.Mail&version=3.4.0-preview.1&prerelease
log4net.Ext.Mail
A MailKit-based SMTP appender for log4net, recommended as the replacement for the deprecated built-in System.Net.Mail.SmtpClient appender.
Overview
log4net.Ext.Mail provides a satellite package that extends log4net with a modern email appender. It uses MailKit instead of the deprecated System.Net.Mail.SmtpClient, so you can reliably send log events via SMTP on modern servers.
The appender exposes the same API as the legacy log4net.Appender.SmtpAppender, making migration straightforward - you only need to change the type attribute in your log4net configuration.
Installation
dotnet add package log4net.Ext.Mail
Quick Start
Configure the appender in your App.config or app.config:
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<log4net>
<appender name="SmtpAppender" type="log4net.Ext.Mail.Appender.SmtpAppender, log4net.Ext.Mail">
<to value="recipient@example.com" />
<from value="sender@example.com" />
<subject value="Log Event" />
<smtpHost value="mail.example.com" />
<port value="587" />
<enableSsl value="true" />
<authentication value="Basic" />
<username value="user@example.com" />
<password value="password" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="ERROR" />
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="SmtpAppender" />
</root>
</log4net>
</configuration>
Then configure log4net in your code:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
Key Differences from the Built-in Appender
| Feature | Built-in | log4net.Ext.Mail.Appender.SmtpAppender |
|---|---|---|
| SMTP Client | System.Net.Mail.SmtpClient (deprecated) |
MailKit |
| TLS Support | Limited | Full (Auto, Explicit, Implicit) |
| Modern Servers | Often fails | ✓ Recommended |
smtpHost |
Optional | Required |
enableSsl |
true/false | true/false (negotiates Auto/None) |
Ntlm auth |
Uses Windows logon | Requires explicit credentials |
Configuration Options
Required
to- recipient email address (comma or semicolon delimited)from- sender email addresssubject- email subject linesmtpHost- SMTP server hostname
Optional
cc- carbon copy recipientsbcc- blind carbon copy recipientsreplyTo- reply-to addressport- SMTP port (default: 25)enableSsl- negotiate TLS/STARTTLS (true/false, default: false)authentication-None,Basic, orNtlm(default:None)username- username for authenticationpassword- password for authenticationpriority- email priority (Low,Normal,High)bufferSize- buffer up to N events before sending (default: 512)lossy- discard buffered events if trigger never fires (default: false)evaluator- custom evaluator to trigger sending (e.g.,LevelEvaluator)
Frameworks
Targets .NET Standard 2.0, so it works with:
- .NET Framework 4.7.1+
- .NET 8+
Documentation
For complete configuration examples and detailed options, see the log4net SmtpAppender documentation.
License
Licensed under the Apache License 2.0. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.4.0-preview.1 | 53 | 8/5/2026 |