[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-user
Subject:    SMTPAppender body empty
From:       "Tim Colson" <tcolson () cisco ! com>
Date:       2004-10-19 21:08:45
Message-ID: 200410192108.OAA13865 () malone ! cisco ! com
[Download RAW message or body]

Howdy folks -

I searched the archives and I've puzzled over this for a while without
success.
 
I have an SMTP appender (below) that I am adding to the root logger. Log4j
1.2.8 is bootrapped from Spring 1.1, then the other appenders are configured
in an ApplicationLog utility class (also created by Spring). This runs great
inside Tomcat 4 & 5 locally -- it sends a nicely formatted error mesg upon
startup. 
 
However, when I deploy into my integration environment (Tomcat 4.1 as part
of the Borland Enterprise Server), the email is sent with an empty mesg.
body. 
 
I had added the latest activation.jar to my web-inf/lib and that seemed to
correct the problem...for a few days. But again, I can see the ERROR mesg in
the file appender, and I receive an email, but the body is empty. 
 
I notice that the local version come across as plaintext, but the
integration server seems send HTML -- perhaps a red herring, but I'm
grasping for any differences between the two. 
 
Ideas?
 
Thanks,
Tim
 
 
 
 
 
    private static Logger AppLog;
....    
AppLog = Logger.getRootLogger();
  
// Create a layout pattern  with every potential bit of info
StringBuffer sbpattern = new StringBuffer("Application: ");
sbpattern.append(Configuration.getProperty("name", "name") );
sbpattern.append("%n----------%n");
sbpattern.append("ENV: ");
sbpattern.append(Configuration.getEnvName());
sbpattern.append("%n");
sbpattern.append("     DATE: %d{ISO8601}     MILLIS: %r%n");
sbpattern.append(" PRIORITY: %p%n");
sbpattern.append("   LOGGER: %c%n%n");
sbpattern.append("CLASSNAME: %C%n");
sbpattern.append("   METHOD: %M LINE: %L%n");
sbpattern.append("   THREAD: %t%n");
sbpattern.append("      NDC: %x%n");
sbpattern.append("  MESSAGE: %m%n");
sbpattern.append("---------- %n%n");

AppLog.info("Configuring EMAIL log with pattern:" + sbpattern.toString());

// Create the layout from the pattern stringbuffer
Layout myEmailLayout = new PatternLayout(sbpattern.toString());

// Create an Email Appender and set various options
SMTPAppender sAppender = new SMTPAppender();
sAppender.setLayout(myEmailLayout);
sAppender.setSubject(Configuration.getProperty("log.email.subject") + " ("
    + Configuration.getProperty("hostname") + ") "  );
sAppender.setSMTPHost(Configuration.getProperty("log.email.SMTPHost"));

if (Configuration.getEnv() == Configuration.ENV_LCL) {
sAppender.setTo(Configuration.getProperty("user.name") + "@cisco.com");
}  else {
sAppender.setTo(Configuration.getProperty("log.email.to"));
}

sAppender.setFrom(Configuration.getProperty("log.email.from"));
// Convert priority config to a PRIORITY object
myPkey = Configuration.getProperty("log.email.priority", "DEBUG");
myP = (Level) LevelMap.get(myPkey);
sAppender.setThreshold(myP);

sAppender.setBufferSize(Integer.parseInt(Configuration.getProperty("log.emai
l.buffersize", "1")));
sAppender.activateOptions();
// Attach the appender to the main Logger
AppLog.addAppender(sAppender);
}
log.error("Application (" + Configuration.getProperty("name") + ") was just
restarted!");
log.info("AppLog init complete.");


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic