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 dawebber <da...@gmail.com> on 2007/10/25 19:56:43 UTC

Question about ConfigurationResetEvent

Hello, all!

I would like to make use of (and piggyback on) log4net's ability to watch
the app config file for changes. I have a Windows Service, which I would
like to have the ability to reread configuration on the fly, after I edit
the configuration file.



I use the following to init the logger:

log4net.ILog _logger = log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);



I can see in the debug output that ConfigurationResetEvent fires when I
change the file. So, that works well.



But, when I try to do this:



_logger.Logger.Repository.ConfigurationResetEvent +=new
log4net.Repository.LoggerRepositoryConfigurationResetEventHandler
(Logger_ConfigurationResetEvent);



My event handler doesn't fire when the config file changes.



Do you guys have any suggestions for me on this?



Thank you in advance.



Regards,
Mark Gimelfarb.

RE: Question about ConfigurationResetEvent

Posted by Marc Lewandowski <ma...@telebill.com>.
While it might boost efficiency slightly, it seems like a bad idea to depend
on the logging layer for core functionality.  Given your requirement and
concern for efficiency, I would write my own (or maybe pilfer L4N's)
watching code, then reconfigure L4N from my code.  The separation of
concerns is much cleaner that way.
 
It sounds like NIH, but that isn't the motive.
 
-Marc

-----Original Message-----
From: dawebber [mailto:dawebber1@gmail.com] 
Sent: Thursday, October 25, 2007 6:00 PM
To: Log4NET User
Subject: Re: Question about ConfigurationResetEvent


Dean,
Thank you for your suggestion. It's a good one, and I have thought about it,
but since L4N is already doing it (running a separate thread with a FSO) I
just wanted to reuse what's already there. If I could just hook in to
ConfigureationResetEvent that would be great. 
Should I be asking this question on log4net-dev also?

Regards,
M.G.


On 10/25/07, Dean Fiala <dfiala@celadonlabs.com
<ma...@celadonlabs.com> > wrote: 

No need to piggyback on to log4net for this, you can use the
FileSystemWatcher class directly, which is yours free with the .NET
Framework....
 
http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
 
 
Regards,
 
Dean
 

  _____  

From: dawebber [mailto:dawebber1@gmail.com] 
Sent: Thursday, October 25, 2007 1:57 PM
To: log4net-user@logging.apache.org
Subject: Question about ConfigurationResetEvent




Hello, all!

I would like to make use of (and piggyback on) log4net's ability to watch
the app config file for changes. I have a Windows Service, which I would
like to have the ability to reread configuration on the fly, after I edit
the configuration file. 

 

I use the following to init the logger:

log4net.ILog _logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()
.DeclaringType);

 

I can see in the debug output that ConfigurationResetEvent fires when I
change the file. So, that works well.

 

But, when I try to do this:

 

_logger.Logger.Repository.ConfigurationResetEvent +=new
log4net.Repository.LoggerRepositoryConfigurationResetEventHandler(Logger_Con
figurationResetEvent);

 

My event handler doesn't fire when the config file changes.

 

Do you guys have any suggestions for me on this?

 

Thank you in advance.

 

Regards,

Mark Gimelfarb. 



Re: Question about ConfigurationResetEvent

Posted by dawebber <da...@gmail.com>.
Dean,
Thank you for your suggestion. It's a good one, and I have thought about it,
but since L4N is already doing it (running a separate thread with a FSO) I
just wanted to reuse what's already there. If I could just hook in to
ConfigureationResetEvent that would be great.
Should I be asking this question on log4net-dev also?

Regards,
M.G.

On 10/25/07, Dean Fiala <df...@celadonlabs.com> wrote:
>
>  No need to piggyback on to log4net for this, you can use the
> FileSystemWatcher class directly, which is yours free with the .NET
> Framework....
>
> http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
>
>
> Regards,
>
> Dean
>
>
>  ------------------------------
> *From:* dawebber [mailto:dawebber1@gmail.com]
> *Sent:* Thursday, October 25, 2007 1:57 PM
> *To:* log4net-user@logging.apache.org
> *Subject:* Question about ConfigurationResetEvent
>
>  Hello, all!
>
> I would like to make use of (and piggyback on) log4net's ability to watch
> the app config file for changes. I have a Windows Service, which I would
> like to have the ability to reread configuration on the fly, after I edit
> the configuration file.
>
>
>
> I use the following to init the logger:
>
> log4net.ILog _logger = log4net.LogManager.GetLogger(
> System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
>
>
>
> I can see in the debug output that ConfigurationResetEvent fires when I
> change the file. So, that works well.
>
>
>
> But, when I try to do this:
>
>
>
> _logger.Logger.Repository.ConfigurationResetEvent +=new
> log4net.Repository.LoggerRepositoryConfigurationResetEventHandler
> (Logger_ConfigurationResetEvent);
>
>
>
> My event handler doesn't fire when the config file changes.
>
>
>
> Do you guys have any suggestions for me on this?
>
>
>
> Thank you in advance.
>
>
>
> Regards,
> Mark Gimelfarb.
>

RE: Question about ConfigurationResetEvent

Posted by Dean Fiala <df...@celadonlabs.com>.
No need to piggyback on to log4net for this, you can use the
FileSystemWatcher class directly, which is yours free with the .NET
Framework....
 
http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
 
 
Regards,
 
Dean
 

  _____  

From: dawebber [mailto:dawebber1@gmail.com] 
Sent: Thursday, October 25, 2007 1:57 PM
To: log4net-user@logging.apache.org
Subject: Question about ConfigurationResetEvent



Hello, all!

I would like to make use of (and piggyback on) log4net's ability to watch
the app config file for changes. I have a Windows Service, which I would
like to have the ability to reread configuration on the fly, after I edit
the configuration file. 

 

I use the following to init the logger:

log4net.ILog _logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()
.DeclaringType);

 

I can see in the debug output that ConfigurationResetEvent fires when I
change the file. So, that works well.

 

But, when I try to do this:

 

_logger.Logger.Repository.ConfigurationResetEvent +=new
log4net.Repository.LoggerRepositoryConfigurationResetEventHandler(Logger_Con
figurationResetEvent);

 

My event handler doesn't fire when the config file changes.

 

Do you guys have any suggestions for me on this?

 

Thank you in advance.

 

Regards,

Mark Gimelfarb.