-
Notifications
You must be signed in to change notification settings - Fork 148
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
Failed db login exception on db creation #533
Comments
Same for me with Serilog.Sinks.MSSqlServer version 6.6.0 |
Hi @alexsrdev and @C-Coretex! I'll take a look at this as soon as I can. Thanks for letting us know. Christian |
This issue also impacted me for a net8 API project. It was particularly tricky to track down because in our environment the database is only missing during certain test stages via docker-compose (spins up new/fresh/empty sql server and spins up the API who's efcore migrations then create the database... or in this case the Startup.cs crashes in builder.Build()). A lot of effort to track this down. And only tracked down by detailed examination of the stack trace and noticing that Serilog was in the middle of it. Workarounds:
|
Note that the autoCreateSqlDatabase flag may require access to the "master" database, regardless of whether or not the logging database exists or not. This fails on Azure SQL (the master database is not user accessible). So... not much of a work around if your app/api actual deployment uses Azure SQL, Here's the error you get for Azure SQL when autoCreateSqlDatabase is true:
|
Hi! Thank you for reporting this. Please be aware that the auto create log table and log database features were intended for convenient local testing and development purposes. Those features are not recommended for production deployments. I think we should state this clearly in the documentation. The rethrow of exceptions in SQL executor class was added because when using the audit sink ( Regarding the access to master db in Azure SQL, I think you are just lacking the correct permissions for the identity which the SQL sink is running with. According to this documentation, access to master db is possible in Azure SQL https://learn.microsoft.com/en-us/azure/azure-sql/database/logins-create-manage?view=azuresql#create-additional-logins-and-users-having-administrative-permissions. Since some of you might experience this issue, can someone please share a complete but simple sample application which we can use to reproduce the problem (using a local SQL instance)? Thank you. Christian |
I will close this issue soon due to inactivity and since we could not reproduce it yet. |
@ckadluba : This happens when you ask the mssql sink to create the log table if doesn't exist and the db hasn't being created yet. E.g (appsettings approach):
If I execute this "dotnet ef database update" command using the terminal, the console receive the error, but it continues and creates the db. Now, when I try to use Visual Studio Package Manager console, the error halt the command execution and it doesn't creates the db. This is the behavior starting at 6.4.0 and later from any type of project so you can tried from your own. |
I have no sample with EF core and MSSQL sink and also no bandwidth to create one right now. If you want to help us to investigating this, please send a complete and simple sample program that we can run to duplicate your issue. It should be easy for you to provide that. |
Sure, no problem. serilog.mssqlsink.test |
Bug Report / Support Request Template
If you are opening a feature request, you can ignore this template. Bug reports and requests for assistance usually require the same basic information described below. This will help us more quickly reproduce and investigate the problem you're reporting. (If you are using Serilog.Sinks.MSSqlServerCore, that package is deprecated, please switch to Serilog.Sinks.MSSqlServer before reporting an issue.)
[x] .NET 8
OS: Running on top of WSL and dotnet/aspnet image
I noticed that since mssqk sink version 6.4.0, the sql executor is re-throwing the exception (see here):
bf1f5e6
bf1f5e6#diff-f8c67af6a71f2771abeac7d9eb21caee190c7f6530085394bd37f24c60c9e65a
Not sure why the change, but this sink should not be trying to connect to database on a db migration execution (e.g. update-database).
When I downgrade to 6.3.0, everything works as expected (db creation is successful).
The text was updated successfully, but these errors were encountered: