Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email logging does not work on the .NET 6. #106

Open
Nikolay-Simonov opened this issue Jan 13, 2022 · 10 comments
Open

Email logging does not work on the .NET 6. #106

Nikolay-Simonov opened this issue Jan 13, 2022 · 10 comments

Comments

@Nikolay-Simonov
Copy link

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.

@ultravelocity
Copy link

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

@wschroers
Copy link

wschroers commented Feb 21, 2022

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.

@janssenr
Copy link

janssenr commented Mar 9, 2022

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

@wschroers
Copy link

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.

@fakhrulhilal
Copy link

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

@janssenr
Copy link

janssenr commented Jul 13, 2022

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.

@xantari
Copy link

xantari commented Nov 17, 2022

Related to #107

@Zero-Xiong
Copy link

Zero-Xiong commented Jun 1, 2023

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" />

@bplus0
Copy link

bplus0 commented Dec 20, 2023

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.

@nblumhardt
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants