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
1条答案
按热度按时间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