-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hello,
we have found following issue:
Error, when debugging log4net:
log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Could not open database connection []. Connection string context [Unable to resolve connection string from ConnectionString, ConnectionStrings, or AppSettings.].
System.InvalidOperationException: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at MicroKnights.Logging.AdoNetAppender.InitializeDatabaseConnection()
Setting connection string at runtime. Although connection string has been set as desired (after setting AdoNetAppender.ConnectionString will bee checked) the above error occurs.
Using .net 6 Application. SQL Server database.
Example connection string: data source=myserver\myinstance;initial catalog=INTERN_TEST;integrated security=false;persist security info=True;User ID=myuser;Password=mypassword
Application with WebApi and multithreading. Multiple log entries per second possible.
Example Code:
adoNetAppender.ConnectionString = connectionStringFromConfig;
adoNetAppender.ActivateOptions(); // here the error occurs (not thrown since handled exception, but effect is, that log entry is missing - error only shows, when log4net debugging active)
Are there any hints how to solve this issue?
Regards
Jörg