Hello.
I am trying to retrieve the connection string within my logging.config (a
separate file outside the web.config in case that is significant) file.
I am using the code below but it seems to use a default(?) logger which is not
defined in my config file (a TextWriterAppender).
I am wondering if this is occurring because the config file cant be located or
the code I am using is just wrong.
Pointers/Tips/Advice very much appreciated.
internal static string LoggerConnectionString
{
get
{
// determine the logging hierarchy
Hierarchy log4netHierarchy = LogManager.GetRepository() as
Hierarchy;
// magic number used because there should only ever be one
appender defined in this application
// the appender variable evaluates to null!
AdoNetAppender appender = log4netHierarchy.Root.Appenders[0] as
AdoNetAppender;
// return connection string if it is found
return appender.ConnectionString ?? string.Empty;
}
}
________________________________
Edinburgh Business School is a Charity Registered in Scotland, SC026900