I have a strange SMTPAppender problem running under Tomcat. I noticed that there have been some extensive discussions on this subject at:
http://www.mail-archive.com/[email protected]/msg06903.html And I have also looked through some older log4j-user message board. However, I have tried all the suggested solutions, but to no avail. I was hoping that someone might be able to help spot the problem. I am using log4j-1.2.14.jar for my SMTPAppender work. Except for the SMTPAppender, all other appenders including SNMPAppender, SyslogAppender, NTEventLogAppender, etc. work beautifully. (Well, except for the NTEventLogAppender which has a small glitch.) Basically, my SMTPAppender configuration works well in a standalone Java application or running under Eclipse. I directed the logging information to a RollingFileAppender and a SMTPAppender at the same time. I got both the messages in the logged file as well as in the e-mail. However, when running the exact same application under Tomcat (5.5.12) using the exact same log4j.properties file, I still got the messages in the logged file, but no e-mails were ever received. For the Tomcat setup, I have tried to place the mail.jar and activation.jar in the following folders (one place at a time, of course): webapp\<myapp>\WEB-INF\lib\ common\lib\ shared\lib\ The results are the same -- I got messages in the logged file, but no e-mails. I had also made sure that there are no other log4j.properties, log4j.xml, or mail.jar, activation.jar in the Tomcat classpath (as suggested in other log4j-user archives). My log4j.properties is nothing special, and here is the segment of log4j's SMTPAppender configuration: ====================================================== # Turn on the debugger to see everything log4j.debug=true # MyLoggedFile to a logged file: log4j.logger.com.MyCompany.MyLoggedClass=DEBUG,FileLogger,SmtpLogger log4j.appender.FileLogger=org.apache.log4j.RollingFileAppender log4j.appender.FileLogger.File=C:/Workspace//logs/my_smtp.log log4j.appender.FileLogger.MaxFileSize=800KB log4j.appender.FileLogger.Threshold=DEBUG log4j.appender.FileLogger.MaxBackupIndex=10 log4j.appender.FileLogger.layout=org.apache.log4j.PatternLayout log4j.appender.FileLogger.layout.ConversionPattern=%-5p %d [%t] (%l) - %m%n # SMTP Appender to an e-mail address: log4j.appender.SmtpLogger=org.apache.log4j.net.SMTPAppender log4j.appender.SmtpLogger.layout=org.apache.log4j.PatternLayout log4j.appender.SmtpLogger.layout.ConversionPattern=%-5p %d{ISO8601} - %m%n log4j.appender.SmtpLogger.Threshold=DEBUG [EMAIL PROTECTED] [EMAIL PROTECTED] log4j.appender.SmtpLogger.SMTPHost=MySMTP.MyCompany.com log4j.appender.SmtpLogger.BufferSize=100 log4j.appender.SmtpLogger.Subject="SMTPAppender Alert (from Tomcat)" ====================================================== As you can see, this is a pretty typical SMTPAppender configuration, and it works in a standalone application. It just does not send out the e-mails under Tomcat -- without showing any e-mail or SMTPAppender related exceptions. It means that the SMTPAppernder found all the required jar files that it needs to do the job. Here is what the debugger info shows in the Tomcat stdout file (the first half of the stdout file is Tomcat related log4j debugging info): ====================================================== log4j: Parsing for [root] with value=[WARN, console]. log4j: Level token is [WARN]. log4j: Category root set to WARN log4j: Parsing appender named "console". log4j: Parsing layout options for "console". log4j: Setting property [conversionPattern] to [%d{ISO8601} %-5p [%C{1}] - %m%n]. log4j: End of parsing for "console". log4j: Parsed "console" options. log4j: Parsing for [org.apache.catalina.session.ManagerBase] with value=[warn,org.apache.catalina.session.ManagerBase]. log4j: Level token is [warn]. log4j: Category org.apache.catalina.session.ManagerBase set to WARN log4j: Parsing appender named "org.apache.catalina.session.ManagerBase". log4j: Parsing layout options for "org.apache.catalina.session.ManagerBase". log4j: End of parsing for "org.apache.catalina.session.ManagerBase". log4j: Parsed "org.apache.catalina.session.ManagerBase" options. log4j: Handling log4j.additivity.org.apache.catalina.session.ManagerBase=[null] log4j: Parsing for [com.MyCompany.MyLoggedClass] with value=[DEBUG,FileLogger,SmtpLogger]. log4j: Level token is [DEBUG]. log4j: Category com.MyCompany.MyLoggedClass set to DEBUG log4j: Parsing appender named "FileLogger". log4j: Parsing layout options for "FileLogger". log4j: Setting property [conversionPattern] to [%-5p %d [%t] (%l) - %m%n]. log4j: End of parsing for "FileLogger". log4j: Setting property [maxFileSize] to [800KB]. log4j: Setting property [threshold] to [DEBUG]. log4j: Setting property [file] to [C:/Workspace//logs/my_smtp.log]. log4j: Setting property [maxBackupIndex] to [10]. log4j: setFile called: C:/Workspace//logs/my_smtp.log, true log4j: setFile ended log4j: Parsed "FileLogger" options. log4j: Parsing appender named "SmtpLogger". log4j: Parsing layout options for "SmtpLogger". log4j: Setting property [conversionPattern] to [%-5p %d{ISO8601} - %m%n]. log4j: End of parsing for "SmtpLogger". log4j: Setting property [from] to [EMAIL PROTECTED] log4j: Setting property [subject] to ["SMTPAppender Alert (from Tomcat)"]. log4j: Setting property [threshold] to [DEBUG]. log4j: Setting property [SMTPHost] to [MySMTP.MyCompany.com]. log4j: Setting property [bufferSize] to [100]. log4j: Setting property [to] to [EMAIL PROTECTED] log4j: Parsed "SmtpLogger" options. log4j: Handling log4j.additivity.com.MyCompany.MyLoggedClass=[null] log4j: Parsing for [org.apache.commons.digester.Digester] with value=[warn,org.apache.commons.digester.Digester]. log4j: Level token is [warn]. log4j: Category org.apache.commons.digester.Digester set to WARN log4j: Parsing appender named "org.apache.commons.digester.Digester". log4j: Parsing layout options for "org.apache.commons.digester.Digester". log4j: End of parsing for "org.apache.commons.digester.Digester". log4j: Parsed "org.apache.commons.digester.Digester" options. log4j: Handling log4j.additivity.org.apache.commons.digester.Digester=[null] log4j: Finished configuring. ====================================================== When I send the messages to SMTP server within the standalone application or within Eclipse, the stdout also dumped out the same log4j debugging information as shown above. So the "log4j.debug=true" flag does not provide any useful debugging information for this problem. Is there any other clues that I might have missed? This seems to have something to do with the Tomcat 5.5.12 or something like that. Thanks. Shuh --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
