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 "Wanner, Nick" <nw...@zolldata.com> on 2005/08/22 23:24:54 UTC

How do you stop watching a configuration file?

I am using log4net to log an application that has multiple clients.
Each client by default is using a single  configuration file.  I am
trying to change the configuration file that a particular client is
using at runtime.  This is so I can set the logging level to a low level
without affecting the runtime performance of the other clients and to
prevent someone from accidentally turning logging off for the other
clients.  I am able to do this using the ConfigureAndWatch method but I
can't stop log4net from watching the original configuration file.  So
whenever either file is modified, log4net is reconfigured.

How can I remove the FileSytemWatcher from the first file so that it
will only watch the second file?

I have looked through the log4net code and it appears that the
FileSystemWatcher is created but is not referenced in any classes so I
can not Disable to Dispose it.

I am using version 1.2.0.30716 of log4net.

Thanks,
Nick

Re: How do you stop watching a configuration file?

Posted by Ron Grabowski <ro...@yahoo.com>.
This is an interesting requirement. I don't think this falls within the
scope of a logger. By that, I mean I don't think log4net needs an
option to specify how how long it should watch its config file. I think
its generally accepted that when you call ConfigureAndWatch you want to
watch the config file indefinitely. If you need other functionality, I
think you need to use your own code to do this. The code in
ConfigureAndWatchHandler is a good starting point. The guts of the
class are only about 15 lines long. That's a neat little class by the
way...its sort of a DelayedFileSystemWatcher.

Should there be another overload for Configure that accepts a FileInfo
and a delegate for when the config file changes? Probably not. Once
you're inside the pre-reset delegate what would you do? I suppose you
could log that the logger is going to reset itself but that's too much
logging even for me :)

My two cents,
Ron

--- "Wanner, Nick" <nw...@zolldata.com> wrote:

> I am using log4net to log an application that has multiple clients.
> Each client by default is using a single  configuration file.  I am
> trying to change the configuration file that a particular client is
> using at runtime.  This is so I can set the logging level to a low
> level
> without affecting the runtime performance of the other clients and to
> prevent someone from accidentally turning logging off for the other
> clients.  I am able to do this using the ConfigureAndWatch method but
> I
> can't stop log4net from watching the original configuration file.  So
> whenever either file is modified, log4net is reconfigured.
> 
> How can I remove the FileSytemWatcher from the first file so that it
> will only watch the second file?
> 
> I have looked through the log4net code and it appears that the
> FileSystemWatcher is created but is not referenced in any classes so
> I
> can not Disable to Dispose it.
> 
> I am using version 1.2.0.30716 of log4net.
> 
> Thanks,
> Nick
>