The API does not allow (at least I couldn't find) certain key features necessary for full run-time code-only configuration, such as getting a list of all appenders specified, the mapping of appenders to logs, etc.
What I did was write a config file to the filesystem and use ConfigureAndWatch() on DOMConfigurator. Then, as the user changes things, it will re-write this file and log4net will pick up the changes. I have to do some locking and such to ensure that two users don't collide while making changes, but other than that it works reasonably well. Are there any plans for updating the API to allow full run-time code-only configuration? Sincerely, Chad -----Original Message----- From: Nicko Cadell [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 9:35 AM To: 'Log4NET User' Subject: RE: config-free log4net? Chad, > I found that there is no real good way to configure log4net > at runtime. There is not a full API set for doing this and > what methods appear to provide some of the functionality > don't seem to work (they're used internally by log4net and > don't seem to be intended to be used externally). The API is there for defining configuration at runtime, but it is not strongly typed. This allows new appenders, layouts, etc to be written without requiring changes to the log4net interfaces. This does mean that configuring log4net programmatically isn't as easy as it could be. One way to configure log4net is to embed an xml config file as an embedded resource in your assembly and use that to configure logging. Stream configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LoggingConfig .xml "); log4net.Config.DOMConfigurator.Configure(configStream); configStream.Close(); This gives you the flexibility of the config file but without the deployment issues. Also the DOMConfigurator merges its changes into the repository, therefore it would be possible to override this embedded configuration by using the DOMConfigurator.ConfigureAndWatch(FileInfo) to monitor for an external config file. This file does not have to exist, but if it does then it will be loaded and merged into the repository. Nicko
