You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "John Scott Brown (JIRA)" <ji...@apache.org> on 2019/02/14 17:49:00 UTC

[jira] [Created] (LOG4J2-2549) SMTP fails send messages that originate from main program.

John Scott Brown created LOG4J2-2549:
----------------------------------------

             Summary: SMTP fails send messages that originate from main program.
                 Key: LOG4J2-2549
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2549
             Project: Log4j 2
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 2.11.0
         Environment: Linux server-2 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
            Reporter: John Scott Brown
             Fix For: 2.11.0
         Attachments: Foo.java, GmailAppender.java, GmailManager.java, LoggerTest.java

In the course of trying to setup Gmail as the SMTP sender I turned to writing a custom appender basically hacking the SMTP code to add needed features to support TLS using port 587.  I wrote a simple test program that logged a single message from the main program, and, that was it. In the course of debugging my modified SMTP appender I found that the append method which called sendEvents to the manager never got called. So, in the configuration I turned on status="debug", to get more info and the smtpDebug flag set true, as well as using the debugger on my customized appender. I also ran the SMTP appender alongside as comparison. Both appender use the same flow control logic but my custom appender modified the properties values to build the javamail session. With the status debug flags turned on I could also see in both appenders, the sendEvents processing was not being called, which I attribute to the append method not being called at the finish of application operation. I tried various things, finally, based on some old hints that other users reported, tried adding another class and calling a method from the new class in the main program that issued a logger.fatal call. That resulted in indication that the sendEvents logic was now being evoked in the SMTP appender. Now, the send failed because of the lack of TLS support which I have reported in a previous issue, but, this is another problem, that probably is fairly rare since most apps will report errors in some other class than from the main method. 

Of course, there is a work around since the main method logic can be encapsulated in another class and simply evoked in the main method. I am attaching the custom appender code that I wrote and the testbed code so that you see that it uses the same SMTP flow control as does SMTPappender.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)