logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Cannot switch between logging levels
Date Tue, 16 Aug 2005 20:31:59 GMT
If you enable debugging inside of log4net: 

 <appSettings>
  <add key="log4net.Internal.Debug" value="true" />
 </appSettings>

and use ConfigureAndWatch to configure log4net, you should see a
message similiar to this when you make a change to your log4net.config
file. The text below was generated when I changed the level of my root
logger from ALL to OFF:

log4net: ConfigureAndWatchHandler: Changed
[c:\inetpub\wwwroot\log4net.config]
log4net: ConfigureAndWatchHandler: Changed
[c:\inetpub\wwwroot\log4net.config]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using file
[c:/inetpub/wwwroot/log4net.config]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using stream
log4net: XmlConfigurator: loading XML configuration
log4net: XmlConfigurator: Configuring Repository
[log4net-default-repository]
log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
log4net: XmlHierarchyConfigurator: Logger [root] Level string is [OFF].
log4net: XmlHierarchyConfigurator: Logger [root] level set to
[name="OFF",value=2147483647].
...

It looks like you're configuring log4net twice. A better approach may
be to use your own AdoNetAppender: 

public class MyAdoNetAppender : AdoNetAppender
{
 protected string ConnectionString 
 {
  get { return base.ConnectionString; }
  set { base.ConnectionString =
ConfigurationSettings.AppSettings["Logger.ConnectionString"]; }
 }
}

Your call to configure log4net will look something like this:

 FileInfo log4netConfig = GetLog4netConfigFile();
 log4net.Config.DOMConfigurator.ConfigureAndWatch(log4netConfig);

--- Jason Goldsmith <JGoldsmith@psmic.com> wrote:

> Hi, I have an ASP.Net application and I store many Session variables,
> so
> I've created a separate config file for log4net (log4net.config)
> because
> if any change is made to the web.config file all my Session variables
> are blown away.  I have configured it with the following:

Mime
View raw message