Patrick,

The best way to do this is to write your own attribute that extends the
ConfiguratorAttribute. You can do this in your own code without needing
to modify log4net at all. It should be relatively simple to create an
attribute that loads the XML config file path from the app settings.

I have attached a simple example that you can use as a basis.

Cheers,

Nicko


> -----Original Message-----
> From: patrick conant [mailto:[EMAIL PROTECTED] 
> Sent: 03 June 2005 19:35
> To: [email protected]
> Subject: System-wide configuration for log4net
> 
> I'm interested in creating a mechanism to have a system-wide 
> configuration file for all .NET applications using log4net.  
> I'd like all logging statements from various web applications 
> and other .NET services to be managed via one configuration 
> file.  I haven't found a good way to do that with the 
> existing code base.  I've used log4j for years, and have 
> always passed "-Dlog4j.configuration=..." into my application 
> startup.  There doesn't seem to be a similar mechanism in log4net.
> 
> I'm considering a couple options for addressing this, and I'd 
> appreciate any recommendations or feedback.
> 
> * Create an ConfiguratorAttribute class that looks for an 
> environment variable ("log4net.configuration") in order to 
> locate the log4net configuration file.
> * Create a ConfiguratorAttribute class that retrieves config 
> file location from a machine.config appSettings key (e.g. 
> <add key=3D"log4net.configuration" 
> value=3D"file:///C:/log4net.xml" />)
> * Update the XmlConfigurator to use one or both of these 
> methods for finding the configuration details.
> 
> Any thoughts on the best way to proceed?
> 
> Thanks,
> Pat.
> 
> 

Attachment: MyXmlConfiguratorAttribute.cs
Description: MyXmlConfiguratorAttribute.cs

Reply via email to