Jul 25

JavaMail can be frustrating when it does not work, even worse when it works on one box but not on another. The following are t a few things to try and track down the cause of your problems.

Enable debug logging

This can be done in your code:
or on the command line:
java -Dmail.debug=true au.com.object.MyMailApp

Use telnet to test connections to mail servers (smtp, pop, imap)

This is useful for telling us if it’s a server or network problem. If telnet can connect ok, then so should your application. For example to test connection to a pop server

telnet mail.example.com 110

If you’re trying to connect to an SMTP server, use 25 instead of 110 for the port number. If you’re trying to connect to an IMAP server use 143 for the port number.

Let us know if you know any other techniques for debugging JavaMail problems.

written by objects \\ tags: ,

Jul 23

Log4j comes with an appender that will send an email when a logging event occurs. The appender class is org.apache.log4j.net.SMTPAppender and the following gives an example of its configuration

<appender name="LogEmail" class="org.apache.log4j.net.SMTPAppender">
  <param name="BufferSize" value="512" />
  <param name="SMTPHost" value="mail.server.com" />
  <param name="From" value="myapp@server.com" />
  <param name="To" value="support@server.com" />
  <param name="Subject" value="Log from myapp" />
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern"
      value="%p %t %c - %m%n" />

written by objects \\ tags: , ,

Jul 18

The default logging configuration that ships with Tomcat 6.0 logs to both catalina.out and also a daily log catalina.yyyy-mm-dd.log. The daily log starts a new file everyday, but catalina.out just continues to grow until your disk fills up.

To make things worse if you want to purge catalina.out you need to restart tomcat to free up the disk space used as tomcat holds the file open.

To avoid this situation what you can do is remove the logging to catalina.out (by removing the handler). This can be achieved by editting conf/logging.properties and changing:

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler


.handlers = 1catalina.org.apache.juli.FileHandler

written by objects \\ tags: , ,