I'm developing a Java Web application using Wildfly (and maven), I wanted to use logentries with Logback as described in https://logentries.com/doc/java/#logback .
I'm also using the AWS SDK for some operations and it seems to be an incompatibility between logentries and the AWS SDK.
If I remove the aws-java-sdk (1.7.11) logentries works like a charm. But as soon as I add it i get the following errors:
14:36:25,329 INFO [stdout] (default task-32) DEBUG: JavaMail version 1.5.1
14:36:25,330 INFO [stdout] (default task-32) DEBUG: URL vfs:/home/lucasferreira/Desenvolvimento/2.Servidores/wildfly-8.1.0.Final/standalone/deployments/server-1.0-SNAPSHOT.war/WEB-INF/lib/aws-java-sdk-1.7.11.jar/META-INF/javamail.providers
14:36:25,330 INFO [stdout] (default task-32) DEBUG: Bad provider entry:
14:36:25,330 INFO [stdout] (default task-32) DEBUG: successfully loaded resource: vfs:/home/lucasferreira/Desenvolvimento/2.Servidores/wildfly-8.1.0.Final/standalone/deployments/server-1.0-SNAPSHOT.war/WEB-INF/lib/aws-java-sdk-1.7.11.jar/META-INF/javamail.providers
14:36:25,331 INFO [stdout] (default task-32) DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
14:36:25,331 INFO [stdout] (default task-32) DEBUG: Tables of loaded providers
14:36:25,331 INFO [stdout] (default task-32) DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], com.amazonaws.services.simpleemail.AWSJavaMailTransport=javax.mail.Provider[TRANSPORT,aws,com.amazonaws.services.simpleemail.AWSJavaMailTransport,Amazon Web Services LLC]}
14:36:25,331 INFO [stdout] (default task-32) DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], aws=javax.mail.Provider[TRANSPORT,aws,com.amazonaws.services.simpleemail.AWSJavaMailTransport,Amazon Web Services LLC]}
14:36:25,332 INFO [stdout] (default task-32) DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
14:36:25,339 INFO [stdout] (default task-32) 14:36:25.338 [default task-32] INFO logentries - Test message
And the message is not received in my logentries account.
After a little research I found out that the amazon SDK messes around with javamail configurations and in the past had some problems with it (http://www.thebuzzmedia.com/javamail-smtp-on-localhost-fails-with-amazon-aws-sdk-in-classpath/). Is there any workaround or fix that i can employ? Is this an AWS SDK problem or a logentries problem?
I got an answer from a Logentries Support engineer:
Stephen Hynes (Logentries) Sep 22 12:04 PM
Hey Lucas,
While we look further into this issue we can do the following workarounds. We can either log to a file and use our Agent (https://logentries.com/doc/agent/) to send the Logs to Logentries. Otherwise what we could possible do is use another API to send Logs to Logentries. This API is currently not documented, however if you wish to try it then you can follow the example (Seen here https://github.com/BrightcoveOS/Diamond/blob/master/src/diamond/handler/logentries_diamond.py#L91)
Essentially you send a POST request to a given address which uses your Log Token as part of the URL. You then need to make to sure that you have your logs in cased in a JSON object which contains the field "events:". If you do not do this you will get an error (however the logs will still go through).
Regards, Stephen
Support Engineer
The Post solution worked by adding info into the events field.
Send a post to https://js.logentries.com/v1/logs/logentries_TOKEN
With the following JSON in the body:
{
"event":{
"key":"value",
"key2":"value2",
"key3" : "value3"
}
}