Closed SandroRiz closed 2 months ago
Hello @SandroRiz!
Thank you for reporting this.
Does your project by any chance have a direct reference on Serilog 3? Could you please share a small but build- and runnable sample program that demonstrates the issue you are facing?
The package referenced before upg were PackageReference Include="Serilog.AspNetCore" Version="8.0.2" / PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" / PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.7.1" /
after upg PackageReference Include="Serilog.AspNetCore" Version="8.0.2" / PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" / PackageReference Include="Serilog.Sinks.MSSqlServer" Version="7.0.0" / CRASH !
adding PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="5.0.0" / it works
you can build any blazor proj with this line in file .csproj
I created a new Blazor Web App (hybrid) project, added your packages including the 7.0.0 MSSQL sink and it does not crash.
I suspect there is an implicit reference to the Serilog.Sinks.PeriodicBatching nuget (probably in any of your dependencies) but that nuget was only restored through the reference in the MSSQL sink.
Please also upgrade any other Serilog packages in your project.
I had to say that with my local development environment (windows 11 + vs 17.3 + kestrel) I didn't have the problem.
Only in production (Win 2019 srv + IIS 10).
Maybe a particular configuration of the server? Nevertheless I though that was justified to report...
Can you do some analysis, where the dependency on Serilog.Sinks.PeriodicBatching in your prod app build comes from? Here is some guidance https://stackoverflow.com/a/8295136/2586938.
Check for "Remove existing files from the destination" in your publish to IIS. We had errors like that, old unused dependencies never got deleted and sometimes got in a way.
Christian, I was not able to run your suggested tools (dependency walker hangs loading the dll and Fusion++1.5 doesn't log anything, probabily IIS issue)
Anyway I tried to reproduce what is deployed (and, yes, I have removed existing files like suggested from vlm)
1) Initial Situation PackageReference Include="Serilog.AspNetCore" Version="8.0.2" / PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" / PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.7.1" /
As you see the PeriodicBatch is added from one of the reference in version 3.1.0.0
2) Upgrade to 7.0.0 PackageReference Include="Serilog.AspNetCore" Version="8.0.2" / PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" / PackageReference Include="Serilog.Sinks.MSSqlServer" Version="7.0.0" /
the Periodicbatch remains 3.1.0.0 and that lead to an error
3) Adding manual PeriodicBatching 5.0.0.0 to resolve PackageReference Include="Serilog.AspNetCore" Version="8.0.2" / PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" / PackageReference Include="Serilog.Sinks.MSSqlServer" Version="7.0.0" / PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="5.0.0" /
Hope this helps...
I checked the sinks you have and none of them seems to have a dependency on Serilog.PeriodicBatching. Also I checked the MSSQL sink 7.0.0 code with the dotnet nuget why
command. It shows not direct or transitive dependency on PeriodicBatching.
Therefore I reckon it must be something in your solution or on your prod environment. Can you create a new simple Blazor app using the MSSQL sink 7.0.0 and deploy and run it on your env?
Here the sample project and a video that reproduces the issue. I have to say that in this video I used a publish profile with Runtime=Portable, while I use always Runtime=x64.. but the results is the same...
https://github.com/user-attachments/assets/7409ebd2-ca37-4943-baf9-29f960b167c4
Hi @SandroRiz , I downloaded your project and published on IIS 10 without any changes and its working. Can you try manually deleting bin and obj folder under your project and .nuget folder under C:\Users\Username (%userprofile%).
Ok, doing housekeeping it works. Thank you
@cancakar35 and @SandroRiz thank you for investigating this issue.
Case closed. :)
Upgrading a asp.net (blazor 8) webapp from 6.7.1 to 7.0.0 the app won't start and IIS reports an HTTP Error 500.30 - ASP.NET Core app failed to start
Digging in the eventviewer of windows server you find that the exception is
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Serilog.Sinks.PeriodicBatching, Version=3.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'. The system cannot find the file specified. File name: 'Serilog.Sinks.PeriodicBatching, Version=3.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'
when calling var app = builder.Build();
Adding manually the Serilog.Sinks.PeriodicBatching (5.0.0.0) from nuget resolves the issue.
Config:
"Serilog": { "Using": [ "Serilog.Sinks.MSSqlServer", "Serilog.Enrichers.Environment" ], "Enrich": [ "FromLogContext", "WithMachineName", "WithEnvironmentName", "WithEnvironmentUserName", "WithClassName" ], "MinimumLevel": { "Default": "Warning", "Override": { "Microsoft": "Warning", "System": "Warning", "Microsoft.AspNetCore": "Warning", "Microsoft.EntityFrameworkCore.Database.Command": "Error" } }, "WriteTo": [ { "Name": "MSSqlServer", "Args": { "connectionString": "Server=.....", "tableName": "Logs", "autoCreateSqlTable": true, "batchPostingLimit": 100, "period": "0.00:00:10", "retainedDataDuration": "30.00:00:00", "columnOptionsSection": { "addStandardColumns": [ "LogEvent" ], "removeStandardColumns": [ "MessageTemplate", "Properties" ] } } } ] }