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 mi...@nl.abnamro.com on 2002/06/17 09:51:45 UTC

DOMConfigurator and the observer pattern.

Hi all,

I'm working on al little project to create an observer pattern around the DOMConfigurator of log4j. (I'm using 1.2.3 b.t.w.)
To do this I've created an ObservableDOMConfigurator which extends DOMConfigurator. It has extra methods to make it a subject. (addObserver,
removeObserver, getObservers and inform)
To inform all observers the subject has changed I overrided the doConfigure(String filename, LoggerRepository hierarchy) which does a
super.doConfigure() and next a this.inform().
Since this didn't work I looked into the log4j code to see what actually happens. I found the following code is called when a change to the config
file is noticed:

public
void doOnChange() {
    new DOMConfigurator().doConfigure(filename,
        LogManager.getLoggerRepository());
  }

This code makes it impossible to override the doConfigure method. I'm pretty sure this is done for a reason, but can anyone explain me why this is
done and not the following is done:

public
void doOnChange() {
    doConfigure(filename,
        LogManager.getLoggerRepository());
  }

Regards,

Misja Heuveling.

Ps. I am not on the List.
---------------------------------------------------------------------------
This message (including any attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorised use or dissemination of this message in whole or in part is strictly prohibited.
Please note that e-mails are susceptible to change.
ABN AMRO Bank N.V. (including its group companies) shall not be liable for the improper or incomplete transmission of the information contained in
this communication nor for any delay in its receipt or damage to your system. ABN AMRO Bank N.V. (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this communication is free of viruses, interceptions or interference.
---------------------------------------------------------------------------





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: DOMConfigurator and the observer pattern.

Posted by Thomas Tuft Muller <tt...@online.no>.
Misja,

DoOnChange is _not_ defined in XMLConfigurator, but in a separate package
protected class; XMLWatchdog, hence you need to write a subclass that
creates a new instance of your subclass instead of XMLConfigurator upon
filechange. You will need to write a configureAndWatch method accordingly.

--

Thomas


| -----Original Message-----
| From: misja.heuveling@nl.abnamro.com
| [mailto:misja.heuveling@nl.abnamro.com]
| Sent: 17 June 2002 08:52
| To: log4j-user@jakarta.apache.org
| Subject: DOMConfigurator and the observer pattern.
|
|
| Hi all,
|
| I'm working on al little project to create an observer pattern
| around the DOMConfigurator of log4j. (I'm using 1.2.3 b.t.w.)
| To do this I've created an ObservableDOMConfigurator which
| extends DOMConfigurator. It has extra methods to make it a
| subject. (addObserver,
| removeObserver, getObservers and inform)
| To inform all observers the subject has changed I overrided the
| doConfigure(String filename, LoggerRepository hierarchy) which does a
| super.doConfigure() and next a this.inform().
| Since this didn't work I looked into the log4j code to see what
| actually happens. I found the following code is called when a
| change to the config
| file is noticed:
|
| public
| void doOnChange() {
|     new DOMConfigurator().doConfigure(filename,
|         LogManager.getLoggerRepository());
|   }
|
| This code makes it impossible to override the doConfigure method.
| I'm pretty sure this is done for a reason, but can anyone explain
| me why this is
| done and not the following is done:
|
| public
| void doOnChange() {
|     doConfigure(filename,
|         LogManager.getLoggerRepository());
|   }
|
| Regards,
|
| Misja Heuveling.
|
| Ps. I am not on the List.
| ------------------------------------------------------------------
| ---------
| This message (including any attachments) is confidential and may
| be privileged. If you have received it by mistake please notify
| the sender by return
| e-mail and delete this message from your system. Any unauthorised
| use or dissemination of this message in whole or in part is
| strictly prohibited.
| Please note that e-mails are susceptible to change.
| ABN AMRO Bank N.V. (including its group companies) shall not be
| liable for the improper or incomplete transmission of the
| information contained in
| this communication nor for any delay in its receipt or damage to
| your system. ABN AMRO Bank N.V. (or its group companies) does not
| guarantee that the
| integrity of this communication has been maintained nor that this
| communication is free of viruses, interceptions or interference.
| ------------------------------------------------------------------
| ---------
|
|
|
|
|
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@jakarta.apache.org>
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this email should be treated in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>