Thanks for your help Mike, however, I think I may have phrased my question
wrongly, and what I meant to ask was how would you use a configuration file
to configure something like a SMTPAppender? For the moment, I am not too
concerned whether the configuration file changes at runtime.
If the SMTPAppender class does not have static fields to represent
properties like the SMTPHost or the From Address, surely you have to go for
the programmatic approach - setSMTPHost() etc, rather than being able to
use a configuration file.

The reason I ask is that in Ceki Gulcu's introductory paper, he uses the
example of a RollingFileAppender which does have static fields, and so he
can use the configuration file option and specify properties in the file
e.g.
log4j.appender.R.=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log

I presume with SMTPAppender, and similar appenders, that use of a
configuration file in this way is not possible?

Thanks again
Lyndsey





Michael Mason <[EMAIL PROTECTED]> on 16/10/2001 14:24:32

Please respond to "LOG4J Users Mailing List"
      <[EMAIL PROTECTED]>



To:   'LOG4J Users Mailing List' <[EMAIL PROTECTED]>
cc:
Subject:  RE: Configuration question


> For example, with SMTPAppender, only a few static fields
> remain, meaning
> that most of the configuration has to be done programmatically e.g.
> SMTPAppender mail = new SMTPAppender();
> mail.setFrom("[EMAIL PROTECTED]");
> mail.setTo("[EMAIL PROTECTED]");
> mail.setSMTPHost("Notes.gateway");
> mail.setSubject("Hello World");
> mail.activateOptions();
>
>
> Can anyone advise whether I am right in thinking this, or
> whether I have got the wrong end of the stick.

I think you might have got the wrong impression. There's lots to
log4j, and it's easy to miss something that you end up needing later.

We use the DOMConfigurator which takes an XML document and uses
it to initialise log4j. There's a utility somewhere inside log4j
that can start a thread and check for changes in your XML config
file, then reconfigure the system when appropriate.

When we started using log4j this "auto update" component didn't
quite work properly and so we wrote our own (a simple thread to
check the last modified timestamp on a file every 10 seconds).
I daresay someone will let you know that it's been fixed in the
latest log4j.

Hope this gives you some ideas -- and the XML bigot in me thinks
that the DOMConfigurator is the way forward anyhow! ;-)

Cheers,
Mike.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to