At 09:47 30.01.2001 +0100, you wrote:
>Hi, thanks for your help!
>Now I've managed to send my first loggingmail using log4j.
>
>Do you know if you can set up a SMTPAppender
>without using a configurationfile?
>
>For the FileAppender I do the following and it works:
>
>// For logging.
>private Category cat;
>         .
>         .
>         .
>// Create a default PatternLayout.
>PatternLayout pl = new
>PatternLayout(PatternLayout.DEFAULT_CONVERSION_PATTERN);
>
>// Create a new FileAppender with the PatternLayout above and the path
>// to where it should write it's output.
>FileAppender fa = new FileAppender(pl, file);
>
>// Add the FileAppender to the Category.
>cat.addAppender(fa);
>
>
>
>I tried the following for the SMTPAppender but it doesn't seem to work:
>
>// For logging.
>private Category cat;
>         .
>         .
>         .
>// Create a new SMTPAppender.
>SMTPAppender smtpa = new SMTPAppender();
>
>// Initialize the SMTPAppender.
>smtpa.setOption(SMTPAppender.TO_OPTION,
>"[EMAIL PROTECTED]");
>smtpa.setOption(SMTPAppender.FROM_OPTION, "someone");
>smtpa.setOption(SMTPAppender.SUBJECT_OPTION, "about");
>smtpa.setOption(SMTPAppender.SMTP_HOST_OPTION, "my_host");
>smtpa.setOption(SMTPAppender.EVALUATOR_CLASS_OPTION,
>"fully.qualified.name.MailEventEvaluator");
>
>// Add the SMTPAppender to the Category.
>cat.addAppender(smtpa);
>
>
>
>Can you see what the problem is?

Matthias,

Yes. You a re missing the activateOptions step. Just call
smtpa.activateOptions() and it should work. Ceki


------
Ceki Gülcü - Independent IT Consultant

av. de Rumine 5            Tel: ++41 21 351 23 15
CH-1005 Lausanne        e-mail: [EMAIL PROTECTED]  or
Switzerland                     [EMAIL PROTECTED]


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

Reply via email to