Menu

#108 Better logging for server DavMail

v4.9.0
closed
logs (1)
5
2018-09-10
2016-08-29
Bazzilic
No

For the server version of DavMail, it would great if there was proper logging. Right now logs only show java exceptions that happen mostly because of some random connection attempts from internets. Would be helpful to see in the logs that an email went through with time stamp, addressee and message size at least. And probably better handling of exceptions, not just dumping the call stack into the log.

Thanks!

Discussion

  • Mickael Guessant

    You mean you want more functional logs, this may indeed be interesting. Can you please provide a sample patch with additional log statements ?

     
  • Bazzilic

    Bazzilic - 2017-02-20

    Sorry for the delay. Right now the logs I have basically look like this:

    2017-02-19 21:05:02,143 ERROR [SmtpConnection-58895] davmail - Remote host closed connection during handshake
    javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
    at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at davmail.AbstractConnection.sendClient(AbstractConnection.java:182)
    at davmail.AbstractConnection.sendClient(AbstractConnection.java:162)
    at davmail.smtp.SmtpConnection.run(SmtpConnection.java:66)
    Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:505)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
    ... 8 more
    2017-02-19 21:05:25,671 ERROR [SmtpConnection-36155] davmail - Remote host closed connection during handshake
    javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
    at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at davmail.AbstractConnection.sendClient(AbstractConnection.java:182)
    at davmail.AbstractConnection.sendClient(AbstractConnection.java:162)
    at davmail.smtp.SmtpConnection.run(SmtpConnection.java:66)
    Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:505)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
    ... 8 more

    This is not very informative, basically useless info exceptions caused by somebody trying to connect to the server (I assume so, at least). It would be much more useful if it was in a form of

    2017-02-20 08:05:17 Unsuccessful connection without SSL from <ip address="">

    Also, would be useful if it actually wrote in the logs when an email went through, e.g.:

    2017-02-17 16:23:12 An email sent by <email> to <email> from <ip address="">, size <xx> KB

     
  • Mickael Guessant

    • status: open --> accepted
     
  • Mickael Guessant

    Added a new optional appender, please add the following lines to your log4j.properties to create a separate connection log file:

    log4j.logger.davmail.connection=DEBUG, ConnectionAppender
    
    log4j.appender.ConnectionAppender=org.apache.log4j.FileAppender
    log4j.appender.ConnectionAppender.file=davmailconnection.log
    log4j.appender.ConnectionAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.ConnectionAppender.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c %x - %m%n
    
     
  • Mickael Guessant

    • status: accepted --> closed
    • Group: Next Release (example) --> v4.9.0
     
  • Mickael Guessant

    Available in 4.9.0

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.