Hi,
This is my first time to try the SMTPAppender. BY running the following
code, I got all logs in a file. But no email and an error message pops up:
log4j:ERROR Message object not configured.
What that means? Thanks.
Yours Jack
import org.apache.log4j.*;
import org.apache.log4j.spi.*;
import org.apache.log4j.net.*;
import java.util.*;
public class SmtpTest {
static Category cat = Category.getInstance(SmtpTest.class.getName());
public static void main(String[] args) throws java.io.IOException
{
PatternLayout pl = new PatternLayout("%d %-5p %x [%t] %c{9} - %m%n");
FileAppender fa = new FileAppender((Layout) pl, "smtptest.log", true);
SMTPAppender sa = new SMTPAppender();
sa.setSMTPHost("mozart");
sa.setFrom(" [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ");
sa.setTo(" [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ");
sa.setSubject("Test email");
sa.setBufferSize(1);
sa.setLayout((Layout) pl);
cat.addAppender(fa);
cat.addAppender(sa);
cat.info("Testing SMTPAppender...");
cat.debug("Some debug log written here...");
cat.error("Some error log written here...");
cat.fatal("Some fatal log written here...");
cat.info("Finished.");
fa.close();
sa.close();
System.exit(0);
}
}
-------------------------------------------------------------
Xinjian Jack Xue, Phone: 317 554 7622