Michael Lam
asked on
how to reference another config file within web.config
hi,
i am trying to use enterprise library logging application in my web pages. i have two options:
1) add all the logging configuration (see attached) to my web.config,
2) have my web.config reference another config file with the logging configuration.
i prefer option 2 because it's more flexible, can someone tell me how to do it? thanks.
i am trying to use enterprise library logging application in my web pages. i have two options:
1) add all the logging configuration (see attached) to my web.config,
2) have my web.config reference another config file with the logging configuration.
i prefer option 2 because it's more flexible, can someone tell me how to do it? thanks.
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Database Trace Listener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp(local:yyyy-MM-dd HH:mm:ss.fff)}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<logFilters>
<add categoryFilterMode="DenyAllExceptAllowed" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Category Filter">
<categoryFilters>
<add name="DEBUG" />
<add name="ERROR" />
<add name="INFO" />
</categoryFilters>
</add>
</logFilters>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="Database Trace Listener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Database Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<connectionStrings>
<add name="Connection String" connectionString="Data Source=arc-tms-db2005;Initial Catalog=Logging;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
ASKER
i tried it using a console app, with Logging.config being the config source, now i am getting this:
"Unable to open configSource file 'Logging.config'. (C:\\dotnet\\FrameworkLogT est\\ELLTe st3\\bin\\ Debug\\ELL Test3.vsho st.exe.con fig line 6)"
But if i open app.config using the EL Config editor, i am able to see the content of loging.config, ie TraceListener type. See attached files.
App.config.txt
Logging.config.txt
FrameworkLogTest.zip.txt
"Unable to open configSource file 'Logging.config'. (C:\\dotnet\\FrameworkLogT
But if i open app.config using the EL Config editor, i am able to see the content of loging.config, ie TraceListener type. See attached files.
App.config.txt
Logging.config.txt
FrameworkLogTest.zip.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, hopefully it will work in web.cofig as well, i will try it out tomorrow.
then put everything into whatever.xml (the root should be LoggingConfiguration)
Cheers,
Greg