Well once again you are right.
[Test]
public void NDCTest()
{
using (log.NDCPush("User2"))
{
log.Debug("log message for user 2 context.");
}
log.NDCPush("User3");
log.Debug("log message for user 3 context.");
log.NDCPop();
}
works fine.
-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 11, 2004 6:27 AM
To: 'Log4NET User'
Subject: RE: config-free log4net?
So long as you are not switching threads and you are able to match up the
push and pops I can't see any reason why you wouldn't be able to proxy the
NDC. All it does is maintain a stack in a thread local slot. Can you provide
more details of the issues you are seeing.
Cheers,
Nicko
> -----Original Message-----
> From: Baldree Matt [mailto:[EMAIL PROTECTED]
> Sent: 10 March 2004 17:48
> To: 'Log4NET User'
> Subject: RE: config-free log4net?
>
> This is basically what I did and it works great. I abstracted
> out all of log4net except when you need to use NDC. You
> cannot delegate to NDC. You must call it directly. :(
>
> -----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("Log
> gingConfig.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
>