سؤال

Is the connectionStringName property of log4net pulling connection strings from web.config as well as from app.config?

I've tried to use it, but for some reason it did not work.

I've put some connection string named 'Logs' in my web.config and then added in my log4net.config an AdoNetAppender with a connectiongStringName set to 'Logs', but it did not seem to work.

Could someone provide some working example of how to use this feature?

Thank you

هل كانت مفيدة؟

المحلول

log4net uses ConfigurationManager.ConnectionStrings[]; to read the connectionstring from the configuration file.

So as long as you specify ConnectionStrings in your app/web.config file like below, it should be all right:

<configuration>
    <connectionStrings>
        <add name="<ConnectionStringName>" connectionString="<actual connection string>" providerName="System.Data.SqlClient"/>
    </connectionStrings>
<configuration>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top