SQL Server NLog issue inserting logs to DATABASE after upgrading .NET 5 to .NET 6 and NLOG

xyhw6mcr  于 2022-12-10  发布在  .NET
关注(0)|答案(1)|浏览(171)

I have the following in my CSPROJ file

<PackageReference Include="NLog.Config" Version="4.7.15" />
    <PackageReference Include="NLog.Schema" Version="5.0.4" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
    <PackageReference Include="NLog" Version="5.0.4" />
    <PackageReference Include="NLog.Database" Version="5.0.4" />
    <PackageReference Include="NLog.Extensions.Logging" Version="5.0.4" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="5.1.4" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.3" />

This is exactly how I have my project setup. how to implement NLOG
Just additionally I am also storing Logs in File like so:

<target xsi:type="File" name="fileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />

The file gets the logs however the database receives nothing. It was working prior to upgrade from .NET 5 to 6 and upgraded NLOG. Anyone know of any changes that I am unaware of?
Internal errors gives me nothing but it forwarded the logs to both file and database.

2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Trace] => dbTarget
2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Debug] => dbTarget
2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Info] => dbTarget
2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Warn] => dbTarget fileTarget
2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Error] => dbTarget fileTarget
2022-09-07 08:41:53.3680 Debug Logger Microsoft.AspNetCore.DataProtection.TypeForwardingActivator [Fatal] => dbTarget fileTarget
qlckcl4x

qlckcl4x1#

I have same issue,
In my case, I add Nlog.DataBase from nuget management
and log can write to database well
Do not need modify any settings

相关问题