elmah / Bootstrapper

Configuration-free registration of ELMAH & more

Home Page:https://elmah.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConnectionStringName via appSettings

WadeTheFade opened this issue · comments

commented

I couldn't find any documentation on available keys/customizations to use in appSettings, so forgive me if this exists, but according to the documentation in order to point ELMAH to a database (SQL) you have to duplicate the connectionString with a connectionString named "elmah:sql".

To use one of these, create a connection string entry in your web.config named elmah:LOGNAME where LOGNAME is the error log name minus the ErrorLog suffix (case-insensitive). So to use SqlErrorLog, create a connection string named elmah:sql.

Its probably just pedantic, but I'd rather not duplicate an existing connection string to rename it. Previous versions of ELMAH had this configuration option:

<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName=""/>

I realize this is a "Configuration-free" and I'm asking for configuration options.

Thanks, in advance.

I couldn't find any documentation on available keys/customizations to use

These are documented in ELMAH's web.config sample and vary with each ErrorLog implementation.

in order to point ELMAH to a database (SQL) you have to duplicate the connectionString with a connectionString named "elmah:sql"

That's correct but why would you be duplicating? Wouldn't it be just a rename?

I realize this is a "Configuration-free" and I'm asking for configuration options.

It's not configuration-free, strictly speaking. It's free of configuration required to register the modules, handlers and configuration sections. All other configuration is kept to a strict minimum and some of it is externalized into separate files, like for filtering and authorization.

commented

These are documented in ELMAH's web.config sample and vary with each ErrorLog implementation.

I tried those configurations and they didn't work when I attempted:
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection"/>
I thought maybe the bootstrapper wasn't reading those configurations, thus the open issue.

That's correct but why would you be duplicating? Wouldn't it be just a rename?

This is what I'd meant when I spoke of duplicating, which is the same connection string, renamed:
<add name="DefaultConnection" connectionString="SAME CONNECTION STRING" />
<add name="elmah:sql" connectionString="SAME CONNECTION STRING" />

If bootstrapper does indeed read those configuration methods linked, I guess I may have been implementing incorrectly. I'll try again.

I apologize for taking your time, thank you.

<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection"/>
I thought maybe the bootstrapper wasn't reading those configurations, thus the open issue.

That's right, it doesn't because using <errorLog> would require registration of that configuration section and the assumption is that you're using Bootstrapper in the first place because you don't want all that registration and extra config sections in your web.config.

I understand your point about connection string duplication. The idea in the initial release was that configuring a connection string should be enough to also specify the error log type but I guess a fallback could be worked in where the error log type is specified via <appSettings>.

commented

Something like this would be cool as a fallback:
<add key="elmah:sql:connectionStringName" value="DefaultConnection" />

You need to use it as
For SqlServer - <add name="elmah:Sql" connectionString="Your Connection String" />
For SQLite - <add name="elmah:SQLite" connectionString="Your Connection String" />
For SqlServerCompact - <add name="elmah:SqlServerCompact" connectionString="Your Connection String" />
For Oracle - <add name="elmah:Oracle" connectionString="Your Connection String" />