You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Eric B." <eb...@hotmail.com> on 2007/05/11 21:11:30 UTC

File Watchdogs

Hi,

I'm trying to use Log4j 1.3alpha-8 watchdog for my XML configuration file,
but am having difficulties.

I've tried the following:

FileWatchdog confiFileWatchdog = new FileWatchdog();
configFileWatchdog.setFile( log4j.xml path );
configFileWatchdog.activateOptions();


But I get the following error message:
ERROR org.apache.log4j.watchdog.FileWatchdog - watchdog requires repository
that supports LoggerRepositoryEx


I'm not entirely sure how to create my loggers such that the repository
supports LoggerRepositoryEx.  Is there something special I need to do in the
log4j.xml file to accomplish this?  Are the watchdogs not yet supported?


If watchdogs are not yet fully supported, how can I programatically reload 
my log4j.xml configuration file?

Thanks,

Eric






---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: File Watchdogs

Posted by "Eric B." <eb...@hotmail.com>.
>> So, if I understand this correctly, I would need to do something like:
>> Logger logger = Logger.get( "logger" );
>> ComponentBase comp = new ComponentBase();
>> comp.setLoggerRepository ( logger.getLoggerRepository());
>>
>> ???  That just doesn't seem right.  Seems like I should need to get  the
>> ComponentBase from somewhere, but not quite sure from where....
>>
>
> FileWatchdog indirectly extends ComponentBase, you would need to call  its 
> setLoggerRepository method.
>
> FileWatchdog confiFileWatchdog = new FileWatchdog();
> configFileWatchdog.setFile( log4j_xml_path );
> configFileWatchdog.setLoggerRepository(LogManager.getLoggerRepository ());
> configFileWatchdog.activateOptions();

Ahhh - new I was missing something obvious.  Thanks.  Works like a charm.

>>
>> I had no idea that 1.3 was geared to be discontinued altogether.   Should 
>> I
>> be abandoning 1.3 completely and revert to 1.2?  I see there is  still 
>> active
>> dev on 1.3, however, so I am confused.  Has there been any dev done  on 
>> 2.0
>> at all?
> log4j 2.0 development is in its infancy.  The enhanced pattern layout 
> component prepared from log4j 1.3 sources for log4j 1.2 is being  hacked 
> to flesh out log4j 2.0 concepts and interfaces, but it is not  yet 
> functional.
>
> Ceki Gulcu who was the prime mover in the log4j 1.3 development has a 
> competing log framework, logBACK (http://logback.qos.ch/), that is  likely 
> what log4j 1.3 would have become but unshackled from any  compatibility 
> expectations with log4j 1.2.  If you really want  something log4j 1.3 like 
> and don't care about log4j 1.2  compatibility, it may be an option.

I don't think I need anything critical from 1.3 anymore, so maybe just a 
rollback to 1.2 will be the best.

Thanks again for the help!

Eric 




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: File Watchdogs

Posted by Curt Arnold <ca...@apache.org>.
On May 13, 2007, at 1:41 AM, Eric B. wrote:

>>> I'm not entirely sure how to create my loggers such that the   
>>> repository
>>> supports LoggerRepositoryEx.  Is there something special I need  
>>> to  do in
>>> the
>>> log4j.xml file to accomplish this?  Are the watchdogs not yet   
>>> supported?
>>>
>>
>> The problem isn't that your repository doesn't support
>> LoggerRepositoryEx.  The problem is that it is not attached to a
>> repository at all.  log4j 1.3 introduced the Component interface  
>> and  one
>> of the essential steps of a component initialization is calling
>> Component.setLoggerRepository() to connect the component to a
>> LoggerRepository.
>
>
> So, if I understand this correctly, I would need to do something like:
> Logger logger = Logger.get( "logger" );
> ComponentBase comp = new ComponentBase();
> comp.setLoggerRepository ( logger.getLoggerRepository());
>
> ???  That just doesn't seem right.  Seems like I should need to get  
> the
> ComponentBase from somewhere, but not quite sure from where....
>

FileWatchdog indirectly extends ComponentBase, you would need to call  
its setLoggerRepository method.

FileWatchdog confiFileWatchdog = new FileWatchdog();
configFileWatchdog.setFile( log4j_xml_path );
configFileWatchdog.setLoggerRepository(LogManager.getLoggerRepository 
());
configFileWatchdog.activateOptions();

>
> The problem is that DOMConfiguration.configureAndWatch has seemed  
> to have
> disappeared from Log4j 1.3 altogether.  And the DOMConfiguration  
> has been
> deprecated in exchange for JoranConfiguration, which also is  
> missing the
> configureAndWatch method.

The methods are in the SVN HEAD, they might not have been in the last  
alpha release.   The entire body of DOMConfigurator.configureAndWatch  
initializes a FileWatchdog, the act of adding the watchdog to the  
PluginRegistry results in the FileWatchdog's setLoggerRepository  
method being called.


>
> I had no idea that 1.3 was geared to be discontinued altogether.   
> Should I
> be abandoning 1.3 completely and revert to 1.2?  I see there is  
> still active
> dev on 1.3, however, so I am confused.  Has there been any dev done  
> on 2.0
> at all?

There was a thread in early April on log4j-dev (http://marc.info/? 
t=117555885500003&r=1&w=2) that revisited the log4j 1.3's  
predicament: Not a big enough change to address today's issues, too  
many changes to be labeled just a minor release.  log4j 1.3's been  
stuck for years, a lot of effort has been applied to make it more  
compatible with log4j 1.2 but really making it compatible with log4j  
1.2 would require undoing things that make it log4j 1.3.    Most of  
the development activity in the past month has been to extract new  
features from the log4j 1.3 code base and package them as companion  
products for log4j 1.2.  Have also been migrating the documentation  
to a Maven driven process with content that would clearly explain  
that log4j 1.3 is essentially abandoned.

log4j 2.0 development is in its infancy.  The enhanced pattern layout  
component prepared from log4j 1.3 sources for log4j 1.2 is being  
hacked to flesh out log4j 2.0 concepts and interfaces, but it is not  
yet functional.

Ceki Gulcu who was the prime mover in the log4j 1.3 development has a  
competing log framework, logBACK (http://logback.qos.ch/), that is  
likely what log4j 1.3 would have become but unshackled from any  
compatibility expectations with log4j 1.2.  If you really want  
something log4j 1.3 like and don't care about log4j 1.2  
compatibility, it may be an option.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: File Watchdogs

Posted by "Eric B." <eb...@hotmail.com>.
>> I'm not entirely sure how to create my loggers such that the  repository
>> supports LoggerRepositoryEx.  Is there something special I need to  do in 
>> the
>> log4j.xml file to accomplish this?  Are the watchdogs not yet  supported?
>>
>
> The problem isn't that your repository doesn't support 
> LoggerRepositoryEx.  The problem is that it is not attached to a 
> repository at all.  log4j 1.3 introduced the Component interface and  one 
> of the essential steps of a component initialization is calling 
> Component.setLoggerRepository() to connect the component to a 
> LoggerRepository.


So, if I understand this correctly, I would need to do something like:
Logger logger = Logger.get( "logger" );
ComponentBase comp = new ComponentBase();
comp.setLoggerRepository ( logger.getLoggerRepository());

???  That just doesn't seem right.  Seems like I should need to get the 
ComponentBase from somewhere, but not quite sure from where....


>> If watchdogs are not yet fully supported, how can I programatically 
>> reload
>> my log4j.xml configuration file?
>>
>
> Kamal Ahmed suggested using the DOMConfigurator.configureAndWatch  method 
> in his message.  I would suggest using that as we are in the  process of 
> abandoning log4j 1.3 and configureAndWatch is supported in  1.2 and is 
> likely to be supported in log4j 2.0's compatibility  layer.  FileWatchdog 
> seems to be only an implementation detail on  log4j 1.3's implementation 
> of configureAndWatch and is unlikely to be  supported in log4j 2.0's 
> compatibility layer.

The problem is that DOMConfiguration.configureAndWatch has seemed to have 
disappeared from Log4j 1.3 altogether.  And the DOMConfiguration has been 
deprecated in exchange for JoranConfiguration, which also is missing the 
configureAndWatch method.

I had no idea that 1.3 was geared to be discontinued altogether.  Should I 
be abandoning 1.3 completely and revert to 1.2?  I see there is still active 
dev on 1.3, however, so I am confused.  Has there been any dev done on 2.0 
at all?

Thanks for the help!

Eric




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: File Watchdogs

Posted by Curt Arnold <ca...@apache.org>.
On May 11, 2007, at 2:11 PM, Eric B. wrote:

> Hi,
>
> I'm trying to use Log4j 1.3alpha-8 watchdog for my XML  
> configuration file,
> but am having difficulties.
>
> I've tried the following:
>
> FileWatchdog confiFileWatchdog = new FileWatchdog();
> configFileWatchdog.setFile( log4j.xml path );
> configFileWatchdog.activateOptions();
>
>
> But I get the following error message:
> ERROR org.apache.log4j.watchdog.FileWatchdog - watchdog requires  
> repository
> that supports LoggerRepositoryEx
>
>
> I'm not entirely sure how to create my loggers such that the  
> repository
> supports LoggerRepositoryEx.  Is there something special I need to  
> do in the
> log4j.xml file to accomplish this?  Are the watchdogs not yet  
> supported?
>

The problem isn't that your repository doesn't support  
LoggerRepositoryEx.  The problem is that it is not attached to a  
repository at all.  log4j 1.3 introduced the Component interface and  
one of the essential steps of a component initialization is calling  
Component.setLoggerRepository() to connect the component to a  
LoggerRepository.

>
> If watchdogs are not yet fully supported, how can I programatically  
> reload
> my log4j.xml configuration file?
>

Kamal Ahmed suggested using the DOMConfigurator.configureAndWatch  
method in his message.  I would suggest using that as we are in the  
process of abandoning log4j 1.3 and configureAndWatch is supported in  
1.2 and is likely to be supported in log4j 2.0's compatibility  
layer.  FileWatchdog seems to be only an implementation detail on  
log4j 1.3's implementation of configureAndWatch and is unlikely to be  
supported in log4j 2.0's compatibility layer.




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: File Watchdogs

Posted by Kamal Ahmed <KA...@webMethods.com>.
3.6 Is there a way to get log4j to automatically reload a configuration
file if it changes?

Yes. Both the DOMConfigurator and the PropertyConfigurator support
automatic reloading through the configureAndWatch method. See the API
documentation for more details.

Because the configureAndWatch launches a separate wathdog thread, and
because there is no way to stop this thread in log4j 1.2, the
configureAndWatch method is unsafe for use in J2EE envrironments where
applications are recycled.

Also: the following code might help you.

URL configURL = new URL("file:"+configFile.getAbsolutePath());

// now watch the file for changes
      FileWatchdog watchdog = new FileWatchdog();
      watchdog.setURL(configURL);
      watchdog.setInterval(2000);
      watchdog.setConfigurator(PropertyConfigurator.class.getName());
 
LogManager.getLoggerRepository().getPluginRegistry().addPlugin(watchdog)
;
      watchdog.activateOptions();


Hope this helps,

-Kamal.

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Eric B.
Sent: Friday, May 11, 2007 3:12 PM
To: log4j-user@logging.apache.org
Subject: File Watchdogs

Hi,

I'm trying to use Log4j 1.3alpha-8 watchdog for my XML configuration
file,
but am having difficulties.

I've tried the following:

FileWatchdog confiFileWatchdog = new FileWatchdog();
configFileWatchdog.setFile( log4j.xml path );
configFileWatchdog.activateOptions();


But I get the following error message:
ERROR org.apache.log4j.watchdog.FileWatchdog - watchdog requires
repository
that supports LoggerRepositoryEx


I'm not entirely sure how to create my loggers such that the repository
supports LoggerRepositoryEx.  Is there something special I need to do in
the
log4j.xml file to accomplish this?  Are the watchdogs not yet supported?


If watchdogs are not yet fully supported, how can I programatically
reload 
my log4j.xml configuration file?

Thanks,

Eric






---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org