Closed stevanuz closed 1 hour ago
Hi @stevanuz!
The code looks correct, so it might be an issue with the connection string or with permissions on your Azure SQL instance.
Can you connect to the DB using the same connection string but with SQL Server Management Studio or some other program on your dev machine?
In the code you have enabled Serilogs SelfLog feature using the Console sink. If the MSSQL sink encounters a problem when trying to write log data to your Azure SQL DB, an error message should be written to the console. Do you see anything there?
Hi @ckadluba ,
Thanks for the reply. There is only one connection string on Azure that is used by Serilog and EF DbContext and it works fine for the DbContext. I can connect fine as well from SSMS. I am not sure how can I actually see the console log as it is deployed on Azure Webapp service. I have not tried to use Azure database connection string and run it on my local machine nevertheless. I will give it a try and let you know.
stevanuz
The easiest way to access the console logs in Azure App Service is to enable log streaming in the portal (App Service logs > Application Logging (Filesystem) = On).
You can then access the logs via the Azure CLI, the Kudu Debug console.
Ok, I tested from my local machine and changed the connection string using SQL Azure and it worked but it is still not working from the Azure Webapp :(
I will try to use file log as you suggested. Thanks.
Ok, it was a connection string issue as the one stored in Azure environment variable was pointing to a wrong database :( Thank you for your help :)
Target framework: .NET 8 OS: Windows server latest
Serilog packages: Serilog.AspNetCore 8.0.3 Serilog.Sinks.MSSqlServer 8.0.0
Azure database: Basic tier
The issue is very basic, there is no exception but it does not log on SQL Azure but it does on my local machine. Initially the AutoCreateSqlTable is set to true but it didn't work on Azure, so I created the logs table manually using EF migrations. But even with that, nothing is being logged when the app started as in configuration the Serilog MinimumLevel is set to Information.
Here is the configuration code:
This is how I called in Program.cs
Here is configuration appSettings:
Can someone please point out what might be wrong or the issue is? Many thanks.
stevanus