[logback-dev] [android] support for SMTPAppender: almost there?
Enrico Spinielli
enrico.spinielli at googlemail.com
Sat Feb 11 16:46:18 CET 2012
Finally I got SMTPAppender working on a real Android application!
BUT (there is always an but, eh?) I had to overcome a strange error in the
configuration:
after having enabled listening to status
messages<http://logback.qos.ch/manual/configuration.html#statusListener>
I
found out I was getting
an error like
ERROR in c.q.l.c.joran.spi.Interpreter@*xx:yy* - no applicable action for
[ssl], current pattern is [[configuration][appender][ssl]]
my email appender was like
<configuration>
...
<appender name="EMAIL"
class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>465</smtpPort>
<ssl>true</ssl>
<username>xyzzy at gmail.com</username>
<password>xyzzy</password>
<to>xyzzy at gmail.com</to>
<from>xyzzy at gmail.com</from>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger - %msg%n"></pattern>
</layout>
</appender>
</configuration>
So in order to have a first working version of SMTPAppender
I had to set ssl = true as default (see code in my github clone)
value instead of false and remove the <ssl> config option.
I tried to investigate further why the <ssl> config did not work but
did not find anything specific in the logback code.
So any hints is welcome.
Thanks in advance
Hope it helps
Ciao
Enrico
On Mon, Feb 6, 2012 at 12:07, Enrico Spinielli <
enrico.spinielli at googlemail.com> wrote:
> Hi,
> it looks like I am close to be able to add support for SMTPAppender.
> I modified the build.xml to include the relevant code, re-introduced the
> tests (SocketAppenderTest.class, DilutedSMTPAppenderTest.class,
> SMTPAppender_GreenTest.class) and (properly?) set the bootclasspath
> to use the android version of javax.mail (see my previous post on
> SMTPAppender).
> I forked logback-android and pushed my changes in
> https://github.com/espinielli/logback-android
>
> It looks like the features I am interested in are ok, since I am
> getting only html/htmlLong
> test cases failing (see below) and I am not interested in sending html
> formatted logs via email.
>
> I will try this version out on my android app soon and provide
> feedback on this list.
>
> Of course I will welcome any feedbacks from anyone on what I did, i.e.
> mistakes,
> bugs ... fixes and ideas are welcome too.
>
> Thanks in advance
> Bye
> Enrico
>
> When I run the tests I get html/htmlLong failing with the following:
> [junit] Testcase: html took 260.281 sec
> [junit] Caused an ERROR
> [junit] Unexpected end of file from server Nested exception:
> Unexpected end of file from server
> [junit] org.dom4j.DocumentException: Unexpected end of file from
> server Nested exception: Unexpected end of file from server
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:343)
> [junit] at
> ch.qos.logback.classic.net.SMTPAppender_GreenTest.html(Unknown Source)
> [junit] Nested exception:
> [junit] java.net.SocketException: Unexpected end of file from server
> [junit] at
> sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:777)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:640)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:774)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:640)
> [junit] at
>
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1252)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:722)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2069)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2032)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:320)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1203)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1090)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1003)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> [junit] at
>
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:343)
> [junit] at
> ch.qos.logback.classic.net.SMTPAppender_GreenTest.html(Unknown Source)
> [junit]
> [junit] Testcase: htmlLong took 736.286 sec
> [junit] Caused an ERROR
> [junit] Unexpected end of file from server Nested exception:
> Unexpected end of file from server
> [junit] org.dom4j.DocumentException: Unexpected end of file from
> server Nested exception: Unexpected end of file from server
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:343)
> [junit] at
> ch.qos.logback.classic.net.SMTPAppender_GreenTest.htmlLong(Unknown
> Source)
> [junit] Nested exception:
> [junit] java.net.SocketException: Unexpected end of file from server
> [junit] at
> sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:777)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:640)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:774)
> [junit] at
> sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:640)
> [junit] at
>
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1252)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:722)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2069)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2032)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:320)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1203)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1090)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1003)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
> [junit] at
>
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> [junit] at
>
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> [junit] at
>
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
> [junit] at org.dom4j.io.SAXReader.read(SAXReader.java:343)
> [junit] at
> ch.qos.logback.classic.net.SMTPAppender_GreenTest.htmlLong(Unknown
> Source)
>
> --
> Enrico Spinielli
> "Do Androids dream of electric sheep?"— Philip K. Dick
> "Hear and forget; see and remember;do and understand."—Mitchel Resnick
> "He who refuses to do arithmetic is doomed to talk nonsense."—John McCarthy
>
--
Enrico Spinielli
"Do Androids dream of electric sheep?"— Philip K. Dick
"Hear and forget; see and remember;do and understand."—Mitchel Resnick
"He who refuses to do arithmetic is doomed to talk nonsense."—John McCarthy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-dev/attachments/20120211/46d4c5f1/attachment.html>
More information about the logback-dev
mailing list