serilog-sinks-email icon indicating copy to clipboard operation
serilog-sinks-email copied to clipboard

Email logging does not work on the .NET 6.

Open Nikolay-Simonov opened this issue 3 years ago • 10 comments

My project settings:

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <LangVersion>10</LangVersion>
        <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
        <PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
        <PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
        <PackageReference Include="Serilog.Sinks.Email" Version="2.4.0" />
        <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
        <PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
    </ItemGroup>
</Project>

SelfLog.Enable(Console.Error) returns the following message:

2022-01-12T13:41:58.1815631Z Exception while emitting periodic batch from Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink: System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task MailKit.MailTransport.Se ndAsync(MimeKit.MimeMessage, System.Threading.CancellationToken, MailKit.ITransferProgress)'. at Serilog.Sinks.Email.EmailSink.EmitBatchAsync(IEnumerable1 events) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Serilog.Sinks.Email.EmailSink.EmitBatchAsync(IEnumerable1 events) at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()

I checked the dll in debug/net6.0 folder. The folder contains MailKit 3.0.0 built for .NET 5. This DLL has SendAsync methods.

Снимок

If you build a project for the .NET 5 platform, email logging works and there are no runtime errors.

Nikolay-Simonov avatar Jan 13 '22 09:01 Nikolay-Simonov

Experiencing the same issue here. It seems the method signature in MailKit changed.

ultravelocity avatar Feb 15 '22 19:02 ultravelocity

Also experiencing the same issue here, any help would be appreciated.

Update: I downgraded Mailkit to version 2.15 as a temporary solution to get it back working again.

wschroers avatar Feb 21 '22 15:02 wschroers

I installed Serilog.Sinks.Email with NuGet Package Manager from Visual Studio 2022. And it installed MailKit 2.6.0. And I experience no problems

janssenr avatar Mar 09 '22 13:03 janssenr

The subject of this tickets is incorrect as it is not a .net 6 issue. The problem is that the Serilog.Sinks.Email packages is not compatible with the latest Mailkit version.

wschroers avatar Mar 14 '22 10:03 wschroers

I installed Serilog.Sinks.Email with NuGet Package Manager from Visual Studio 2022. And it installed MailKit 2.6.0. And I experience no problems

I have the same version as you, but still having the problem, it doesn't send any email. Serilog.Sinks.Email 2.4.0 MailKit 2.6.0 .NET6

fakhrulhilal avatar Jul 13 '22 11:07 fakhrulhilal

My Project settings are:

<TargetFramework>net6.0</TargetFramework>
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Email" Version="2.4.0" />

@fakhrulhilal Can you post the project which is not working? Then I will take a look.

janssenr avatar Jul 13 '22 11:07 janssenr

Related to #107

xantari avatar Nov 17 '22 01:11 xantari

still got the same issue.

I have installed

<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Email" Version="2.4.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="MailKit" Version="4.0.0" />

Zero-Xiong avatar Jun 01 '23 07:06 Zero-Xiong

December 2023 update. This is still an issue with .net 8 and the latest version of Serilog.Sinks.Email. I had to downgrade my mailkit version, and the reinstal Serilog.Sinks.Email.. and the logs started coming.

I would love to find the proper place to track this as Mailkit is way outta date now.

bplus0 avatar Dec 20 '23 04:12 bplus0

3.0.0-dev-* updates the project to MailKit 4; now on NuGet but needs some testing and feedback as quite a bit of surgery was done :-) - all help appreciated!

nblumhardt avatar Dec 23 '23 06:12 nblumhardt