How to provide custom connection string for Logging Application Block instead of using the one in .c
Posted
by Rory
on Stack Overflow
See other posts from Stack Overflow
or by Rory
Published on 2009-12-29T01:24:43Z
Indexed on
2010/04/28
0:43 UTC
Read the original article
Hit count: 462
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
© Stack Overflow or respective owner