You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by "Michael S. Collier" <mi...@centricconsulting.com> on 2005/09/03 00:59:32 UTC

Configurable configuration file location

Is there any way to specify the configuration file log4net should use via a
configuration file?  For example, let's say I have three different
applications that all want to use the same log4net configuration.  Is it
possible to set a value in each application's app.config file that log4net
would use as the path to its configuration file?  Or, would it be up to each
application to read such a configuration setting and programmatically
configure log4net?

 

I haven't seen anything in the log4net documentation about this, but thought
I would ask just in case.

 

 

Thanks,

Mike


Re: Configurable configuration file location

Posted by Ron Grabowski <ro...@yahoo.com>.
If you're asking if one of the Configure methods looks for a certain
key in an application's appSettings before looking for the log4net node
in the app.config the answer is no. You'd have to write code to do that
yourself:

 XmlConfigurator.Configure(
  new FileInfo(
   ConfigurationSettings.AppSettings["log4net-config-file"]));

--- "Michael S. Collier" <mi...@centricconsulting.com> wrote:

> Is there any way to specify the configuration file log4net should use
> via a
> configuration file?  For example, let's say I have three different
> applications that all want to use the same log4net configuration.  Is
> it
> possible to set a value in each application's app.config file that
> log4net
> would use as the path to its configuration file?  Or, would it be up
> to each
> application to read such a configuration setting and programmatically
> configure log4net?
> 
>  
> 
> I haven't seen anything in the log4net documentation about this, but
> thought
> I would ask just in case.
> 
>  
> 
>  
> 
> Thanks,
> 
> Mike

RE: Configurable configuration file location

Posted by Ron Grabowski <ro...@yahoo.com>.
According to these two articles:

 http://www.devx.com/vb2themax/Tip/18880
 http://weblogs.asp.net/pwilson/archive/2003/04/09/5261.aspx

The syntax for including an external appSettings file is:

 <appSettings file="YourSettings.config">
  <add key="KeyToOverride" value="Original" />
  <add key="KeyToNotOverride" value="Standard" />
 </appSettings>

--- Thomas <to...@tomwindows.com> wrote:

> I believe this is possible in .NET 2.0 as it allows for the ability
> to
> "include" configuration files. To do this in 1.x, would be trickier.
> You
> could assemble the configuration file manually, combining the
> information
> from the log4net configuration file. Another solution would be to
> have the
> log4net assembly look specifically for a log4net configuration file
> instead
> of the application's configuration file.
> 
>  
> 
> HTH
> 
> 
> 
>  
> 
> Thomas
> 
>  
> 
>  
> 
>  
> 
>   _____  
> 
> From: Michael S. Collier
> [mailto:michael.collier@centricconsulting.com] 
> Sent: Friday, September 02, 2005 4:00 PM
> To: 'Log4NET User'
> Subject: Configurable configuration file location
> 
>  
> 
> Is there any way to specify the configuration file log4net should use
> via a
> configuration file?  For example, let's say I have three different
> applications that all want to use the same log4net configuration.  Is
> it
> possible to set a value in each application's app.config file that
> log4net
> would use as the path to its configuration file?  Or, would it be up
> to each
> application to read such a configuration setting and programmatically
> configure log4net?
> 
>  
> 
> I haven't seen anything in the log4net documentation about this, but
> thought
> I would ask just in case.
> 
>  
> 
>  
> 
> Thanks,
> 
> Mike
> 
> 


RE: Configurable configuration file location

Posted by Thomas <to...@tomwindows.com>.
I believe this is possible in .NET 2.0 as it allows for the ability to
"include" configuration files. To do this in 1.x, would be trickier. You
could assemble the configuration file manually, combining the information
from the log4net configuration file. Another solution would be to have the
log4net assembly look specifically for a log4net configuration file instead
of the application's configuration file.

 

HTH



 

Thomas

 

 

 

  _____  

From: Michael S. Collier [mailto:michael.collier@centricconsulting.com] 
Sent: Friday, September 02, 2005 4:00 PM
To: 'Log4NET User'
Subject: Configurable configuration file location

 

Is there any way to specify the configuration file log4net should use via a
configuration file?  For example, let's say I have three different
applications that all want to use the same log4net configuration.  Is it
possible to set a value in each application's app.config file that log4net
would use as the path to its configuration file?  Or, would it be up to each
application to read such a configuration setting and programmatically
configure log4net?

 

I haven't seen anything in the log4net documentation about this, but thought
I would ask just in case.

 

 

Thanks,

Mike