Better logging for server DavMail
Brought to you by:
mguessan
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!
You mean you want more functional logs, this may indeed be interesting. Can you please provide a sample patch with additional log statements ?
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
Added a new optional appender, please add the following lines to your log4j.properties to create a separate connection log file:
Available in 4.9.0