How to provide custom connection string for Logging Application Block instead of using the one in .c
- by Rory
I'm modifying an existing winforms application to use the Logging Application Block. For historical reasons this app gets its main database connection string from the registry, and I'd like the Logging Application Block to use the same details for logging to the database. How can I do this?
The approaches i can think of are:
1) Create a new TraceListener and implement the same sort of functionality as in FormattedDatabaseTraceListener. If I take this approach, should I inherit from CustomTraceListener, and if so how do I pass an attribute of the formatter to use?
2) Create a new ConfigurationSource that provides different details when asked for the database connection. All other requests would be passed through to a FileConfigurationSource, but when asked for the database connection details the object would read the appropriate bits from the registry instead.
but it's not obvious which is more appropriate, or how to go about doing it. Any suggestions?
I'm using EntLib 3.1.
thanks,
-Rory